/Users/lyon/j4p/src/classUtils/gui/ComponentEditor.java

1    package classUtils.gui; 
2     
3    import gui.run.*; 
4     
5    import javax.swing.*; 
6    import java.awt.*; 
7    import java.awt.event.WindowAdapter; 
8    import java.awt.event.WindowEvent; 
9     
10    
11   public class ComponentEditor { 
12    
13       static JDesktopPane desktop = new JDesktopPane(); 
14       static final JFrame f = new JFrame("Component Editor"); 
15    
16       public static void main(String[] args) { 
17    
18           final Container c = f.getContentPane(); 
19           c.setBackground(Color.white); 
20           desktop.setLayout(null); 
21           desktop.setBackground(Color.white); 
22           c.add(desktop); 
23    
24    
25           JMenuBar mb = new JMenuBar(); 
26    
27           JMenu menuFile = new JMenu("File"); 
28           menuFile.add(new RunMenuItem("Exit") { 
29               public void run() { 
30                   System.exit(0); 
31               } 
32           }); 
33    
34           JMenu menuComponent = new JMenu("Add Component"); 
35    
36           menuComponent.add(new RunMenuItem("add Button") { 
37               public void run() { 
38                   desktop.add(new RunButton("Button") { 
39                       public void run() { 
40                           //do the button thing 
41                       } 
42                   }); 
43               } 
44           }); 
45    
46           menuComponent.add(new RunMenuItem("add Slider") { 
47               public void run() { 
48                   desktop.add(new RunSlider(0, 0, 100, 50) { 
49                       public void run() { 
50                           //do the slider thing 
51                       } 
52                   }); 
53               } 
54           }); 
55    
56           menuComponent.add(new RunMenuItem("add TextField") { 
57               public void run() { 
58                   desktop.add(new RunTextFieldOld("TextField") { 
59                       public void run() { 
60                           //do the textfield thing 
61                       } 
62                   }); 
63               } 
64           }); 
65    
66           menuComponent.add(new RunMenuItem("add List") { 
67               public void run() { 
68                   String[] data = {"This", "is", "a", "List"}; 
69                   desktop.add(new RunList(data) { 
70                       public void run() { 
71                           //do the list thing; 
72                       } 
73                   }); 
74               } 
75           }); 
76    
77           menuComponent.add(new RunMenuItem("add PasswordField") { 
78               public void run() { 
79                   desktop.add(new RunPasswordField("Password Field") { 
80                       public void run() { 
81                           //do the passwordfield thing 
82                       } 
83                   }); 
84               } 
85           }); 
86    
87           menuComponent.add(new RunMenuItem("add CheckBox") { 
88               public void run() { 
89                   desktop.add(new RunCheckBox("CheckBox") { 
90                       public void run() { 
91                           //do the checkbox thing 
92                       } 
93                   }); 
94               } 
95           }); 
96    
97           mb.add(menuFile); 
98           mb.add(menuComponent); 
99    
100          f.setJMenuBar(mb); 
101   
102          f.addWindowListener(new WindowAdapter() { 
103              public void windowClosing(WindowEvent e) { 
104                  System.exit(0); 
105              } 
106          }); 
107          f.setSize(600, 600); 
108          f.setVisible(true); 
109   
110      } 
111   
112  }