/Users/lyon/j4p/src/addBk/address/TextFieldPanel.java

1    package addBk.address; 
2     
3    import javax.swing.*; 
4    import java.awt.*; 
5    import java.awt.event.ActionEvent; 
6    import java.awt.event.ActionListener; 
7     
8    public class TextFieldPanel 
9            extends JPanel 
10           implements 
11           ActionListener, 
12           AddressSettable { 
13       JTextField t0 = 
14               new JTextField("my number vc"); 
15       JTextField t1 = 
16               new JTextField("203-454-1234 fax"); 
17       JTextField t2 = 
18               new JTextField("203-543-2134 cell"); 
19    
20       public void actionPerformed( 
21               ActionEvent e) { 
22           System.out.println( 
23                   "command=" 
24                   + e.getActionCommand() 
25           ); 
26       } 
27    
28       public void setAddress(AddressRecord a) { 
29           t0.setText(a.getPhone1()); 
30           t1.setText(a.getPhone2()); 
31           t2.setText(a.getPhone3()); 
32       } 
33    
34       TextFieldPanel() { 
35           setLayout( 
36                   new GridLayout(0, 1)); 
37           add(t0); 
38           add(t1); 
39           add(t2); 
40           t0.addActionListener(this); 
41           t1.addActionListener(this); 
42           t2.addActionListener(this); 
43    
44       } 
45   }