/* * BankApplet.java * * Created on April 20, 2005, 9:37 AM */ /** * * @author levenick */ public class BankApplet extends java.applet.Applet { Bank theBank = new Bank(); /** Initializes the applet BankApplet */ public void init() { try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } setSize(400,300); } /** This method is called from within the init() method to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents displayButton = new java.awt.Button(); theTF = new java.awt.TextField(); acct1Button = new java.awt.Button(); acct2Button = new java.awt.Button(); acct3Button = new java.awt.Button(); label1 = new java.awt.Label(); label2 = new java.awt.Label(); setLayout(null); displayButton.setLabel("display balance"); displayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { displayButtonActionPerformed(evt); } }); add(displayButton); displayButton.setBounds(150, 30, 100, 24); theTF.setText(" "); theTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { theTFActionPerformed(evt); } }); add(theTF); theTF.setBounds(250, 60, 100, 20); acct1Button.setLabel("account 1"); acct1Button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { acct1ButtonActionPerformed(evt); } }); add(acct1Button); acct1Button.setBounds(170, 140, 69, 24); acct2Button.setLabel("account 2"); acct2Button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { acct2ButtonActionPerformed(evt); } }); add(acct2Button); acct2Button.setBounds(240, 140, 69, 24); acct3Button.setLabel("account 3"); acct3Button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { acct3ButtonActionPerformed(evt); } }); add(acct3Button); acct3Button.setBounds(320, 140, 69, 24); label1.setText("balance"); add(label1); label1.setBounds(260, 40, 70, 20); label2.setText("withdrawal amount"); add(label2); label2.setBounds(240, 80, 130, 20); }//GEN-END:initComponents private void acct3ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acct3ButtonActionPerformed theBank.selectAccount3(); }//GEN-LAST:event_acct3ButtonActionPerformed private void acct2ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acct2ButtonActionPerformed theBank.selectAccount2(); }//GEN-LAST:event_acct2ButtonActionPerformed private void acct1ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acct1ButtonActionPerformed theBank.selectAccount1(); }//GEN-LAST:event_acct1ButtonActionPerformed private void theTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_theTFActionPerformed theBank.withdraw(Integer.parseInt(theTF.getText())); }//GEN-LAST:event_theTFActionPerformed private void displayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_displayButtonActionPerformed theTF.setText("$" + theBank.getBalance()); }//GEN-LAST:event_displayButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private java.awt.Button acct1Button; private java.awt.Button acct2Button; private java.awt.Button acct3Button; private java.awt.Button displayButton; private java.awt.Label label1; private java.awt.Label label2; private java.awt.TextField theTF; // End of variables declaration//GEN-END:variables }