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

1    package addBk.address; 
2     
3    import gui.ClosableJFrame; 
4    import gui.run.RunMenu; 
5    import gui.run.RunMenuItem; 
6     
7    import javax.swing.*; 
8    import java.awt.*; 
9     
10   import xml.adbk.AddressBook; 
11    
12   public class AddressBookFrame 
13           extends ClosableJFrame 
14           implements AddressSettable { 
15       Help help = new Help(); 
16       AddressBook adbk = new AddressBook(); 
17       AddressPanel ap = 
18               new AddressPanel(); 
19       TextButtonPanel tbp = 
20               new TextButtonPanel(); 
21       JTextField nameField = 
22               new JTextField("Name Field"); 
23       LabelSelectorPanel lsp = 
24               new LabelSelectorPanel(); 
25    
26       public void setAddress(AddressRecord a) { 
27           ap.setAddress(a); 
28           tbp.setAddress(a); 
29           nameField.setText(a.getName()); 
30           repaint(); 
31       } 
32    
33       public void init() { 
34           Container c = getContentPane(); 
35           c.setLayout(new BorderLayout()); 
36           c.add(nameField, "North"); 
37           c.add(ap, "Center"); 
38           c.add(tbp, "South"); 
39           setJMenuBar(getMenuBar2()); 
40           setSize(300, 300); 
41           setVisible(true); 
42    
43       } 
44    
45       public  JMenuBar getMenuBar2() { 
46           JMenuBar mb = new JMenuBar(); 
47           mb.add(getFileMenu()); 
48           return mb; 
49       } 
50    
51       public  RunMenu getFileMenu() { 
52           RunMenu fileMenu = new RunMenu("[File"); 
53           fileMenu.add(new RunMenuItem("[open{control o}") { 
54               public void run() { 
55                   adbk.open(); 
56               } 
57           }); 
58           fileMenu.add(new RunMenuItem("[save as csv{control s}") { 
59               public void run() { 
60                   adbk.saveAsCsv(); 
61               } 
62           }); 
63           fileMenu.add(new RunMenuItem("[x save as xml{control x}") { 
64               public void run() { 
65                   adbk.saveAsXml(); 
66               } 
67           }); 
68           fileMenu.add(new RunMenuItem("[Help{control h}") { 
69               public void run() { 
70                   help.display(); 
71               } 
72           }); 
73           return fileMenu; 
74       } 
75    
76       public static void main(String args[]) { 
77           AddressBookFrame 
78                   adf = new AddressBookFrame(); 
79           adf.init(); 
80    
81       } 
82   } 
83