import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; /** * Main program for MVC Account example, * based on example in chapter 3 of Deitel, Deitel, and Santry * * Ignore compiler message "Some input files use or override a deprecated API." * (will discuss in class) */ public class Main extends JFrame { public static void main (String [] args) { java.awt.EventQueue.invokeLater (new Runnable() { public void run() { new Main (); } }); } public Main () { // Window setup setSize (465, 500); setLayout (new GridLayout (0, 1, 30, 30)); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); /* * Create M, V, C for first account * all in their own JPanel */ String acctname = "Checking"; JPanel p1 = new JPanel (); p1.setBorder (new TitledBorder (acctname)); Model m1 = new Model (acctname, 100); p1.add (new Controller (m1)); // Put the 2 Views in their own JPanel JPanel vp1 = new JPanel (); vp1.setLayout (new GridLayout (0, 1, 10, 10)); vp1.add (new TextView (m1)); vp1.add (new GraphView (m1)); p1.add (vp1); add (p1); /* * Ditto, second account */ acctname = "Savings"; JPanel p2 = new JPanel (); p2.setBorder (new TitledBorder (acctname)); Model m2 = new Model (acctname, 1000); p2.add (new Controller (m2)); // Put the 2 Views in their own JPanel JPanel vp2 = new JPanel (); vp2.setLayout (new GridLayout (0, 1, 10, 10)); vp2.add (new TextView (m2)); vp2.add (new GraphView (m2)); p2.add (vp2); add (p2); setVisible (true); } }