public class BankAccountDriver
1: // BankAccountDriver.java
2: // Adapted from an example by Tony Sintes.
3: // This Driver hooks the model and view together
4: // and then places the view into a frame for display.
6: import java.awt.event.WindowListener;
7: import java.awt.event.WindowAdapter;
8: import java.awt.event.WindowEvent;
9: import javax.swing.JFrame;
12: public class BankAccountDriver
13: {
14: public static void main(String [] args)
15: {
16: BankAccountModel model = new BankAccountModel(10000.00);
17: BankAccountView view = new BankAccountView(model);
19: JFrame frame = new JFrame();
20: WindowAdapter wa = new WindowAdapter()
21: // The following is an example of an "anonymous inner class"
22: // and the reason you get a file called BankAccount$1.class
23: // when you compile. Use of the WindowAdapter class allows
24: // you to implement only the "listener method" of interest.
25: {
26: public void windowClosing(WindowEvent e)
27: {
28: System.exit(0);
29: }
30: };
31: frame.addWindowListener(wa);
32: frame.getContentPane().add(view);
33: frame.pack();
34: frame.show();
35: }
36: }