/* * BankDBMS.java * * Created on October 13, 2004, 2:44 PM */ /** * * @author levenick */ public class BankDBMS extends java.awt.Frame { private Bank theBank; /** Creates new form BankDBMS */ public BankDBMS() { initComponents(); //theChoice.addItem("this"); //theChoice.addItem("that"); //theChoice.addItem("the other thing"); setBounds(100,100,500,500); theBank = new Bank(theChoice); theBank.save(); } /** This method is called from within the constructor 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 theChoice = new java.awt.Choice(); theTA = new java.awt.TextArea(); withdrawTF = new java.awt.TextField(); balanceTF = new java.awt.TextField(); label1 = new java.awt.Label(); editButton = new java.awt.Button(); setLayout(null); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); theChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { newChoice(evt); } }); add(theChoice); theChoice.setBounds(430, 20, 100, 20); add(theTA); theTA.setBounds(20, 10, 330, 360); withdrawTF.setText("100"); withdrawTF.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { withdrawTFActionPerformed(evt); } }); add(withdrawTF); withdrawTF.setBounds(400, 170, 100, 30); balanceTF.setText(" "); add(balanceTF); balanceTF.setBounds(410, 280, 71, 20); label1.setText("balance"); add(label1); label1.setBounds(410, 250, 70, 30); editButton.setLabel("edit"); editButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editButtonActionPerformed(evt); } }); add(editButton); editButton.setBounds(460, 100, 40, 24); pack(); }//GEN-END:initComponents private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed theBank.edit(); }//GEN-LAST:event_editButtonActionPerformed private void withdrawTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_withdrawTFActionPerformed theBank.withdraw(Integer.parseInt(withdrawTF.getText())); displayCurrentBalance(); }//GEN-LAST:event_withdrawTFActionPerformed private void displayCurrentBalance() { balanceTF.setText("" + theBank.getBalance()); } private void newChoice(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_newChoice String item = theChoice.getSelectedItem(); System.out.println("new choice from the choice: " + item); theBank.setCurrentAccount(item); displayCurrentBalance(); }//GEN-LAST:event_newChoice /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit(0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main(String args[]) { new BankDBMS().show(); } // Variables declaration - do not modify//GEN-BEGIN:variables private java.awt.TextField balanceTF; private java.awt.Button editButton; private java.awt.Label label1; private java.awt.Choice theChoice; private java.awt.TextArea theTA; private java.awt.TextField withdrawTF; // End of variables declaration//GEN-END:variables }