143 |
preferences.add(new JCheckBoxMenuItem("World Peace")); |
preferences.add(new JCheckBoxMenuItem("World Peace")); |
144 |
edit.add(preferences); |
edit.add(preferences); |
145 |
|
|
146 |
|
JMenu examples = new JMenu("Examples"); |
147 |
|
new PopUpAction("Buttons", |
148 |
|
mkPanel(new JComponent[] |
149 |
|
{mkBigButton("mango"), |
150 |
|
mkBigButton("guava"), |
151 |
|
mkBigButton("lemon")}), |
152 |
|
examples); |
153 |
|
|
154 |
|
new PopUpAction("Toggles", |
155 |
|
mkToggle("cool and refreshing"), |
156 |
|
examples); |
157 |
|
|
158 |
|
new PopUpAction("Checkbox", |
159 |
|
mkCheckbox("ice cold"), |
160 |
|
examples); |
161 |
|
|
162 |
|
new PopUpAction("Radio", |
163 |
|
mkRadio("delicious"), |
164 |
|
examples); |
165 |
|
|
166 |
|
new PopUpAction("Slider", |
167 |
|
mkSliders(), |
168 |
|
examples); |
169 |
|
|
170 |
|
new PopUpAction("List", |
171 |
|
mkListPanel(new String[] { "hello", |
172 |
|
"this", |
173 |
|
"is", |
174 |
|
"a", |
175 |
|
"list", |
176 |
|
"that", |
177 |
|
"wraps", |
178 |
|
"over"}), |
179 |
|
examples); |
180 |
|
|
181 |
|
new PopUpAction("Scrollbar", |
182 |
|
mkScrollBar(), |
183 |
|
examples); |
184 |
|
|
185 |
|
new PopUpAction("Viewport", |
186 |
|
mkViewportBox(mkBigButton("View Me!")), |
187 |
|
examples); |
188 |
|
|
189 |
|
new PopUpAction("ScrollPane", |
190 |
|
mkScrollPane(mkBigButton("Scroll Me!")), |
191 |
|
examples); |
192 |
|
|
193 |
|
new PopUpAction("TabPane", |
194 |
|
mkTabs(new String[] {"happy", |
195 |
|
"sad", |
196 |
|
"indifferent"}), |
197 |
|
examples); |
198 |
|
|
199 |
|
new PopUpAction("Spinner", |
200 |
|
mkSpinner(), |
201 |
|
examples); |
202 |
|
|
203 |
|
new PopUpAction("TextField", |
204 |
|
mkTextField("Hello, World!"), |
205 |
|
examples); |
206 |
|
|
207 |
|
new PopUpAction("ColorChooser", |
208 |
|
mkColorChooser(), |
209 |
|
examples); |
210 |
|
|
211 |
|
new PopUpAction("ComboBox", |
212 |
|
mkComboBox(new String[] {"Stop", |
213 |
|
"Software", |
214 |
|
"Hoarders", |
215 |
|
"Support", |
216 |
|
"GNU!"}), |
217 |
|
examples); |
218 |
|
|
219 |
|
new PopUpAction("Editor", |
220 |
|
mkEditorPane(), |
221 |
|
examples); |
222 |
|
|
223 |
|
new PopUpAction("Tree", |
224 |
|
mkTree(), |
225 |
|
examples); |
226 |
|
|
227 |
help.add(new JMenuItem("just play with the widgets")); |
help.add(new JMenuItem("just play with the widgets")); |
228 |
help.add(new JMenuItem("and enjoy the sensation of")); |
help.add(new JMenuItem("and enjoy the sensation of")); |
229 |
help.add(new JMenuItem("your neural connections growing")); |
help.add(new JMenuItem("your neural connections growing")); |
230 |
|
|
231 |
bar.add(file); |
bar.add(file); |
232 |
bar.add(edit); |
bar.add(edit); |
233 |
|
bar.add(examples); |
234 |
bar.add(help); |
bar.add(help); |
235 |
return bar; |
return bar; |
236 |
} |
} |
568 |
JComponent component = (JComponent) frame.getContentPane(); |
JComponent component = (JComponent) frame.getContentPane(); |
569 |
component.setLayout(new BorderLayout()); |
component.setLayout(new BorderLayout()); |
570 |
component.add(mkToolBar(), BorderLayout.NORTH); |
component.add(mkToolBar(), BorderLayout.NORTH); |
571 |
component.add(mkTabbedPane(), BorderLayout.CENTER); |
JPanel main = new JPanel(); |
572 |
component.add(mkButtonBar(), BorderLayout.SOUTH); |
main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); |
573 |
|
main.add(mkTabbedPane()); |
574 |
|
main.add(mkButtonBar()); |
575 |
|
component.add(main, BorderLayout.CENTER); |
576 |
frame.pack(); |
frame.pack(); |
577 |
frame.show(); |
frame.show(); |
578 |
} |
} |
762 |
private JComponent inner; |
private JComponent inner; |
763 |
private String name; |
private String name; |
764 |
|
|
765 |
|
PopUpAction(String n, JComponent i, JMenu m) |
766 |
|
{ |
767 |
|
name = n; |
768 |
|
inner = i; |
769 |
|
|
770 |
|
JMenuItem item = new JMenuItem(name); |
771 |
|
item.addActionListener(this); |
772 |
|
m.add(item); |
773 |
|
} |
774 |
|
|
775 |
PopUpAction(String n, JComponent i, JPanel p) |
PopUpAction(String n, JComponent i, JPanel p) |
776 |
{ |
{ |
777 |
name = n; |
name = n; |