H:\CSC120\Java\lec15\src\MUPanel.java
 1 import java.awt.*;
 2 import javax.swing.*;
 3 
 4 public class MUPanel extends JPanel {
 5 
 6     private BankAccount acct1, acct2;
 7 
 8     // constructor method
 9     public MUPanel() {
10         setLayout(null);
11         setPreferredSize(new Dimension(800, 100));
12         setName("CSC 120 Lecture # 15");
13         setBackground(Color.WHITE);
14 
15         acct1 = new BankAccount("000123", "Sammy Scarton", 40.00);
16         acct2 = new BankAccount("099999", "Helga Schwartz", 500.00);
17         
18         
19         System.out.println("Initially, the balances are:");
20         System.out.println();
21         System.out.println("  acct1:  " + acct1.toString());
22         System.out.println("  acct2:  " + acct2.toString());
23         System.out.println();
24         
25         acct1.makeAWithdrawal(20.00);
26         acct2.makeADeposit(100.00);
27         acct2.makeAWithdrawal(250.00);
28         acct1.makeAWithdrawal(75.00);
29         
30         System.out.println("==================================");
31         System.out.println("After some transactions, the balances are:");
32         System.out.println();
33         System.out.println("  acct1:  " + acct1.toString());
34         System.out.println("  acct2:  " + acct2.toString());
35         
36     } // end of constructor
37     
38     @Override
39     public void paintComponent(Graphics g) {
40         super.paintComponent(g); // This line must be first in this method!
41 
42         g.setFont(new Font("SansSerif", Font.BOLD, 24));
43         g.drawString("Look in the Java Console for Output", 250, 60);
44                 
45     } // end of paintComponent()
46     
47     
48     
49        
50     
51     
52     
53     /***********************************************
54      * Do NOT change or delete anything below here!
55      ***********************************************/
56     public void frame() {
57         for (Component c: getComponents())
58             c.setSize(c.getPreferredSize());
59         JFrame f = new JFrame(getName());
60         f.setContentPane(this);
61         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
62         f.pack();
63         f.setVisible(true);    
64     }
65 
66     public static void main(String args[]){new MUPanel().frame();}
67 
68 } // end of class MUPanel
69