Java Reference
In-Depth Information
9 {
10
public static void
main(String[] args)
11 {
12 ATM theATM;
13
14
try
15 {
16 Bank theBank =
new
Bank();
17 theBank.readCustomers(
Ðcustomers.txtÑ
);
18 theATM =
new
ATM(theBank);
19 }
20
catch
(IOException e)
21 {
22 JOptionPane.showMessageDialog(
null
,
23
ÐError opening accounts
file.Ñ
);
24
return
;
25 }
26
27 JFrame frame =
new
ATMFrame(theATM);
28 frame.setTitle(
ÐFirst National Bank of
JavaÑ
);
29 frame.setDefaultCloseOperation(JFrame.EXIT_ON
30 frame.setVisible(
true
);
31 }
32 }
571
572
ch12/atm/ATMFrame.java
1
import
java.awt.FlowLayout;
2
import
java.awt.GridLayout;
3
import
java.awt.event.ActionEvent;
4
import
java.awt.event.ActionListener;
5
import
javax.swing.JButton;
6
import
javax.swing.JFrame;
7
import
javax.swing.JPanel;
8
import
javax.swing.JTextArea;
9
10 /**
11
A frame displaying the components of an ATM.
12 */
13
public class
ATMFrame
extends
JFrame