KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > testapp > interactive > testscreen > ButtonTest


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.testapp.interactive.testscreen;
31
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34 import java.util.Locale JavaDoc;
35
36 import nextapp.echo2.app.Alignment;
37 import nextapp.echo2.app.Button;
38 import nextapp.echo2.app.CheckBox;
39 import nextapp.echo2.app.Color;
40 import nextapp.echo2.app.Column;
41 import nextapp.echo2.app.Extent;
42 import nextapp.echo2.app.Font;
43 import nextapp.echo2.app.Grid;
44 import nextapp.echo2.app.Insets;
45 import nextapp.echo2.app.Label;
46 import nextapp.echo2.app.LayoutDirection;
47 import nextapp.echo2.app.RadioButton;
48 import nextapp.echo2.app.SplitPane;
49 import nextapp.echo2.app.button.AbstractButton;
50 import nextapp.echo2.app.button.ButtonGroup;
51 import nextapp.echo2.app.button.ToggleButton;
52 import nextapp.echo2.app.event.ActionEvent;
53 import nextapp.echo2.app.event.ActionListener;
54 import nextapp.echo2.app.event.ChangeEvent;
55 import nextapp.echo2.app.event.ChangeListener;
56 import nextapp.echo2.app.layout.SplitPaneLayoutData;
57 import nextapp.echo2.testapp.interactive.ButtonColumn;
58 import nextapp.echo2.testapp.interactive.InteractiveApp;
59 import nextapp.echo2.testapp.interactive.StyleUtil;
60 import nextapp.echo2.testapp.interactive.Styles;
61 import nextapp.echo2.testapp.interactive.TestGrid;
62
63 /**
64  * Interactive test module for <code>AbstractButton</code>-derived components.
65  */

66 public class ButtonTest
67 extends SplitPane {
68
69     /**
70      * Interface used to apply style information to all test components.
71      */

72     private interface Applicator {
73         
74         /**
75          * Applies style information.
76          *
77          * @param button the target button
78          */

79         public void apply(AbstractButton button);
80     }
81     
82     private List JavaDoc buttonList;
83     
84     /**
85      * Writes <code>ActionEvent</code>s to console.
86      */

87     private ActionListener actionListener = new ActionListener() {
88
89         /**
90          * @see nextapp.echo2.app.event.ActionListener#actionPerformed(nextapp.echo2.app.event.ActionEvent)
91          */

92         public void actionPerformed(ActionEvent e) {
93             ((InteractiveApp) getApplicationInstance()).consoleWrite(e.toString());
94         }
95     };
96     
97     /**
98      * Writes <code>ChangeEvent</code>s to console.
99      */

100     private ChangeListener changeListener = new ChangeListener() {
101
102         /**
103          * @see nextapp.echo2.app.event.ChangeListener#stateChanged(nextapp.echo2.app.event.ChangeEvent)
104          */

105         public void stateChanged(ChangeEvent e) {
106             ((InteractiveApp) getApplicationInstance()).consoleWrite(e.toString());
107         }
108     };
109     
110     public ButtonTest() {
111         super(SplitPane.ORIENTATION_HORIZONTAL, new Extent(250, Extent.PX));
112         setStyleName("DefaultResizable");
113
114         SplitPaneLayoutData splitPaneLayoutData;
115         
116         Column controlGroupsColumn = new Column();
117         controlGroupsColumn.setCellSpacing(new Extent(5));
118         controlGroupsColumn.setStyleName("TestControlsColumn");
119         add(controlGroupsColumn);
120
121         final TestGrid testGrid = new TestGrid();
122         splitPaneLayoutData = new SplitPaneLayoutData();
123         splitPaneLayoutData.setInsets(new Insets(15));
124         testGrid.setLayoutData(splitPaneLayoutData);
125         add(testGrid);
126         
127         buttonList = new ArrayList JavaDoc();
128         
129         Button button;
130         testGrid.addHeaderRow("Button");
131         
132         button = new Button();
133         testGrid.addTestRow("No Content", button);
134         buttonList.add(button);
135
136         button = new Button("Test Button");
137         testGrid.addTestRow("Text", button);
138         buttonList.add(button);
139         
140         button = new Button(Styles.ICON_LOGO);
141         testGrid.addTestRow("Icon", button);
142         buttonList.add(button);
143         
144         button = new Button("Test Button", Styles.ICON_LOGO);
145         testGrid.addTestRow("Text and Icon", button);
146         buttonList.add(button);
147         
148         CheckBox checkBox;
149         testGrid.addHeaderRow("CheckBox");
150
151         checkBox = new CheckBox();
152         testGrid.addTestRow("No Content", checkBox);
153         buttonList.add(checkBox);
154
155         checkBox = new CheckBox("Test CheckBox");
156         testGrid.addTestRow("Text", checkBox);
157         buttonList.add(checkBox);
158         
159         checkBox = new CheckBox(Styles.ICON_LOGO);
160         testGrid.addTestRow("Icon", checkBox);
161         buttonList.add(checkBox);
162         
163         checkBox = new CheckBox("Test CheckBox", Styles.ICON_LOGO);
164         testGrid.addTestRow("Text and Icon", checkBox);
165         buttonList.add(checkBox);
166         
167         RadioButton radioButton;
168         testGrid.addHeaderRow("RadioButton");
169         
170         ButtonGroup buttonGroup = new ButtonGroup();
171
172         radioButton = new RadioButton();
173         radioButton.setGroup(buttonGroup);
174         testGrid.addTestRow("No Content", radioButton);
175         buttonList.add(radioButton);
176
177         radioButton = new RadioButton("Test RadioButton");
178         radioButton.setGroup(buttonGroup);
179         testGrid.addTestRow("Text", radioButton);
180         buttonList.add(radioButton);
181         
182         radioButton = new RadioButton(Styles.ICON_LOGO);
183         radioButton.setGroup(buttonGroup);
184         testGrid.addTestRow("Icon", radioButton);
185         buttonList.add(radioButton);
186         
187         radioButton = new RadioButton("Test RadioButton", Styles.ICON_LOGO);
188         radioButton.setGroup(buttonGroup);
189         testGrid.addTestRow("Text and Icon", radioButton);
190         buttonList.add(radioButton);
191
192         buttonGroup = new ButtonGroup();
193         Grid radioGrid = new Grid();
194         radioGrid.setInsets(new Insets(10));
195         for (int i = 1; i <= 4; ++i) {
196             radioButton = new RadioButton(Integer.toString(i));
197             radioButton.setGroup(buttonGroup);
198             radioGrid.add(radioButton);
199             buttonList.add(radioButton);
200         }
201         testGrid.addTestRow("Separate ButtonGroup", radioGrid);
202         
203         radioButton = new RadioButton("Test");
204         buttonList.add(radioButton);
205         testGrid.addTestRow("Null ButtonGroup", radioButton);
206
207         ButtonColumn controlsColumn;
208         
209         // Create 'AbstractButton Controls Group'
210

211         controlsColumn = new ButtonColumn();
212         controlGroupsColumn.add(controlsColumn);
213         
214         controlsColumn.add(new Label("General Settings"));
215         
216         controlsColumn.addButton("Toggle Container Cell Spacing", new ActionListener() {
217             public void actionPerformed(ActionEvent e) {
218                 if (testGrid.getInsets() != null && testGrid.getInsets().getTop().equals(new Extent(5))) {
219                     testGrid.setInsets(new Insets(0));
220                 } else {
221                     testGrid.setInsets(new Insets(5));
222                 }
223             }
224         });
225         controlsColumn.addButton("Add ActionListener", new ActionListener() {
226             public void actionPerformed(ActionEvent e) {
227                 apply(new Applicator() {
228                     public void apply(AbstractButton button) {
229                         button.addActionListener(actionListener);
230                     }
231                 });
232             }
233         });
234         controlsColumn.addButton("Remove ActionListener", new ActionListener() {
235             public void actionPerformed(ActionEvent e) {
236                 apply(new Applicator() {
237                     public void apply(AbstractButton button) {
238                         button.removeActionListener(actionListener);
239                     }
240                 });
241             }
242         });
243         controlsColumn.addButton("Add ChangeListener", new ActionListener() {
244             public void actionPerformed(ActionEvent e) {
245                 apply(new Applicator() {
246                     public void apply(AbstractButton button) {
247                         if (button instanceof ToggleButton) {
248                             ((ToggleButton) button).addChangeListener(changeListener);
249                         }
250                     }
251                 });
252             }
253         });
254         controlsColumn.addButton("Remove ChangeListener", new ActionListener() {
255             public void actionPerformed(ActionEvent e) {
256                 apply(new Applicator() {
257                     public void apply(AbstractButton button) {
258                         if (button instanceof ToggleButton) {
259                             ((ToggleButton) button).removeChangeListener(changeListener);
260                         }
261                     }
262                 });
263             }
264         });
265         controlsColumn.addButton("Set StyleName = Null", new ActionListener() {
266             public void actionPerformed(ActionEvent e) {
267                 apply(new Applicator() {
268                     public void apply(AbstractButton button) {
269                         button.setStyleName(null);
270                     }
271                 });
272             }
273         });
274         controlsColumn.addButton("Set StyleName = Default", new ActionListener() {
275             public void actionPerformed(ActionEvent e) {
276                 apply(new Applicator() {
277                     public void apply(AbstractButton button) {
278                         button.setStyleName("Default");
279                     }
280                 });
281             }
282         });
283         controlsColumn.addButton("Set Text = Short", new ActionListener() {
284             public void actionPerformed(ActionEvent e) {
285                 apply(new Applicator() {
286                     public void apply(AbstractButton button) {
287                         if (button.getText() != null) {
288                             button.setText("Test Button");
289                         }
290                     }
291                 });
292             }
293         });
294         controlsColumn.addButton("Set Text = Long", new ActionListener() {
295             public void actionPerformed(ActionEvent e) {
296                 apply(new Applicator() {
297                     public void apply(AbstractButton button) {
298                         if (button.getText() != null) {
299                             button.setText("This button has a longer label. The quick brown fox jumps over the lazy brown dog.");
300                         }
301                     }
302                 });
303             }
304         });
305         
306         controlsColumn.addButton("Toggle ToolTip Text", new ActionListener(){
307             public void actionPerformed(ActionEvent e) {
308                 apply(new Applicator() {
309                     public void apply(AbstractButton button) {
310                         if (button.getToolTipText() == null) {
311                             button.setToolTipText("This is a tool tip.");
312                         } else {
313                             button.setToolTipText(null);
314                         }
315                     }
316                 });
317             }
318         });
319         controlsColumn.addButton("Toggle Enabled State", new ActionListener() {
320             public void actionPerformed(ActionEvent e) {
321                 apply(new Applicator() {
322                     public void apply(AbstractButton button) {
323                         button.setEnabled(!button.isEnabled());
324                     }
325                 });
326             }
327         });
328         controlsColumn.addButton("Toggle Enabled State (Container)", new ActionListener() {
329             public void actionPerformed(ActionEvent e) {
330                 testGrid.setEnabled(!testGrid.isEnabled());
331             }
332         });
333
334         controlsColumn = new ButtonColumn();
335         controlGroupsColumn.add(controlsColumn);
336         
337         controlsColumn.add(new Label("AbstractButton Controls"));
338         
339         // Base Settings
340
controlsColumn.addButton("Set Foreground", new ActionListener() {
341             public void actionPerformed(ActionEvent e) {
342                 final Color color = StyleUtil.randomColor();
343                 apply(new Applicator() {
344                     public void apply(AbstractButton button) {
345                         button.setForeground(color);
346                     }
347                 });
348             }
349         });
350         controlsColumn.addButton("Clear Foreground", new ActionListener() {
351             public void actionPerformed(ActionEvent e) {
352                 apply(new Applicator() {
353                     public void apply(AbstractButton button) {
354                         button.setForeground(null);
355                     }
356                 });
357             }
358         });
359         controlsColumn.addButton("Set Background", new ActionListener() {
360             public void actionPerformed(ActionEvent e) {
361                 final Color color = StyleUtil.randomColor();
362                 apply(new Applicator() {
363                     public void apply(AbstractButton button) {
364                         button.setBackground(color);
365                     }
366                 });
367             }
368         });
369         controlsColumn.addButton("Clear Background", new ActionListener() {
370             public void actionPerformed(ActionEvent e) {
371                 apply(new Applicator() {
372                     public void apply(AbstractButton button) {
373                         button.setBackground(null);
374                     }
375                 });
376             }
377         });
378         controlsColumn.addButton("Set Font", new ActionListener() {
379             public void actionPerformed(ActionEvent e) {
380                 final Font font = StyleUtil.randomFont();
381                 apply(new Applicator() {
382                     public void apply(AbstractButton button) {
383                         button.setFont(font);
384                     }
385                 });
386             }
387         });
388         controlsColumn.addButton("Clear Font", new ActionListener() {
389             public void actionPerformed(ActionEvent e) {
390                 apply(new Applicator() {
391                     public void apply(AbstractButton button) {
392                         button.setFont(null);
393                     }
394                 });
395             }
396         });
397         controlsColumn.addButton("Set Background Image", new ActionListener() {
398             public void actionPerformed(ActionEvent e) {
399                 apply(new Applicator() {
400                     public void apply(AbstractButton button) {
401                         button.setBackgroundImage(Styles.BUTTON_BACKGROUND_IMAGE);
402                     }
403                 });
404             }
405         });
406         controlsColumn.addButton("Clear Background Image", new ActionListener() {
407             public void actionPerformed(ActionEvent e) {
408                 apply(new Applicator() {
409                     public void apply(AbstractButton button) {
410                         button.setBackgroundImage(null);
411                     }
412                 });
413             }
414         });
415         controlsColumn.addButton("Set Line Wrap = true", new ActionListener() {
416             public void actionPerformed(ActionEvent e) {
417                 apply(new Applicator() {
418                     public void apply(AbstractButton button) {
419                         button.setLineWrap(true);
420                     }
421                 });
422             }
423         });
424         controlsColumn.addButton("Set Line Wrap = false", new ActionListener() {
425             public void actionPerformed(ActionEvent e) {
426                 apply(new Applicator() {
427                     public void apply(AbstractButton button) {
428                         button.setLineWrap(false);
429                     }
430                 });
431             }
432         });
433         controlsColumn.addButton("Set Width = Default", new ActionListener() {
434             public void actionPerformed(ActionEvent e) {
435                 apply(new Applicator() {
436                     public void apply(AbstractButton button) {
437                         button.setWidth(null);
438                     }
439                 });
440             }
441         });
442         controlsColumn.addButton("Set Width = 300px", new ActionListener() {
443             public void actionPerformed(ActionEvent e) {
444                 apply(new Applicator() {
445                     public void apply(AbstractButton button) {
446                         button.setWidth(new Extent(300, Extent.PX));
447                     }
448                 });
449             }
450         });
451         controlsColumn.addButton("Set Width = 50%", new ActionListener() {
452             public void actionPerformed(ActionEvent e) {
453                 apply(new Applicator() {
454                     public void apply(AbstractButton button) {
455                         button.setWidth(new Extent(50, Extent.PERCENT));
456                     }
457                 });
458             }
459         });
460         controlsColumn.addButton("Set Height = Default", new ActionListener() {
461             public void actionPerformed(ActionEvent e) {
462                 apply(new Applicator() {
463                     public void apply(AbstractButton button) {
464                         button.setHeight(null);
465                     }
466                 });
467             }
468         });
469         controlsColumn.addButton("Set Height = 100px", new ActionListener() {
470             public void actionPerformed(ActionEvent e) {
471                 apply(new Applicator() {
472                     public void apply(AbstractButton button) {
473                         button.setHeight(new Extent(100, Extent.PX));
474                     }
475                 });
476             }
477         });
478         controlsColumn.addButton("Set Insets = Default", new ActionListener() {
479             public void actionPerformed(ActionEvent e) {
480                 apply(new Applicator() {
481                     public void apply(AbstractButton button) {
482                         button.setInsets(null);
483                     }
484                 });
485             }
486         });
487         controlsColumn.addButton("Set Insets = 10/5px", new ActionListener() {
488             public void actionPerformed(ActionEvent e) {
489                 apply(new Applicator() {
490                     public void apply(AbstractButton button) {
491                         button.setInsets(new Insets(10, 5));
492                     }
493                 });
494             }
495         });
496         controlsColumn.addButton("Set Insets = 30px", new ActionListener() {
497             public void actionPerformed(ActionEvent e) {
498                 apply(new Applicator() {
499                     public void apply(AbstractButton button) {
500                         button.setInsets(new Insets(30, 30));
501                     }
502                 });
503             }
504         });
505
506         // Rollover Effect Settings
507

508         controlsColumn = new ButtonColumn();
509         controlGroupsColumn.add(controlsColumn);
510         
511         controlsColumn.add(new Label("Rollover Effects"));
512
513         controlsColumn.addButton("Enable Rollover Effects", new ActionListener() {
514             public void actionPerformed(ActionEvent e) {
515                 apply(new Applicator() {
516                     public void apply(AbstractButton button) {
517                         button.setRolloverEnabled(true);
518                     }
519                 });
520             }
521         });
522         controlsColumn.addButton("Disable Rollover Effects", new ActionListener() {
523             public void actionPerformed(ActionEvent e) {
524                 apply(new Applicator() {
525                     public void apply(AbstractButton button) {
526                         button.setRolloverEnabled(false);
527                     }
528                 });
529             }
530         });
531         controlsColumn.addButton("Set Rollover Icon", new ActionListener() {
532             public void actionPerformed(ActionEvent e) {
533                 apply(new Applicator() {
534                     public void apply(AbstractButton button) {
535                         if (button.getIcon() != null) {
536                             button.setRolloverIcon(Styles.ROLLOVER_ICON_LOGO);
537                         }
538                     }
539                 });
540             }
541         });
542         controlsColumn.addButton("Clear Rollover Icon", new ActionListener() {
543             public void actionPerformed(ActionEvent e) {
544                 apply(new Applicator() {
545                     public void apply(AbstractButton button) {
546                         if (button.getIcon() != null) {
547                             button.setRolloverIcon(null);
548                         }
549                     }
550                 });
551             }
552         });
553         controlsColumn.addButton("Set Rollover Foreground", new ActionListener() {
554             public void actionPerformed(ActionEvent e) {
555                 final Color color = StyleUtil.randomColor();
556                 apply(new Applicator() {
557                     public void apply(AbstractButton button) {
558                         button.setRolloverForeground(color);
559                     }
560                 });
561             }
562         });
563         controlsColumn.addButton("Clear Rollover Foreground", new ActionListener() {
564             public void actionPerformed(ActionEvent e) {
565                 apply(new Applicator() {
566                     public void apply(AbstractButton button) {
567                         button.setRolloverForeground(null);
568                     }
569                 });
570             }
571         });
572         controlsColumn.addButton("Set Rollover Background", new ActionListener() {
573             public void actionPerformed(ActionEvent e) {
574                 final Color color = StyleUtil.randomColor();
575                 apply(new Applicator() {
576                     public void apply(AbstractButton button) {
577                         button.setRolloverBackground(color);
578                     }
579                 });
580             }
581         });
582         controlsColumn.addButton("Clear Rollover Background", new ActionListener() {
583             public void actionPerformed(ActionEvent e) {
584                 apply(new Applicator() {
585                     public void apply(AbstractButton button) {
586                         button.setRolloverBackground(null);
587                     }
588                 });
589             }
590         });
591         controlsColumn.addButton("Set Rollover Font", new ActionListener() {
592             public void actionPerformed(ActionEvent e) {
593                 final Font font = StyleUtil.randomFont();
594                 apply(new Applicator() {
595                     public void apply(AbstractButton button) {
596                         button.setRolloverFont(font);
597                     }
598                 });
599             }
600         });
601         controlsColumn.addButton("Clear Rollover Font", new ActionListener() {
602             public void actionPerformed(ActionEvent e) {
603                 apply(new Applicator() {
604                     public void apply(AbstractButton button) {
605                         button.setRolloverFont(null);
606                     }
607                 });
608             }
609         });
610         controlsColumn.addButton("Set Rollover Background Image", new ActionListener() {
611             public void actionPerformed(ActionEvent e) {
612                 apply(new Applicator() {
613                     public void apply(AbstractButton button) {
614                         button.setRolloverBackgroundImage(Styles.BUTTON_ROLLOVER_BACKGROUND_IMAGE);
615                     }
616                 });
617             }
618         });
619         controlsColumn.addButton("Clear Rollover Background Image", new ActionListener() {
620             public void actionPerformed(ActionEvent e) {
621                 apply(new Applicator() {
622                     public void apply(AbstractButton button) {
623                         button.setRolloverBackgroundImage(null);
624                     }
625                 });
626             }
627         });
628         
629         // Pressed Effect Settings
630

631         controlsColumn = new ButtonColumn();
632         controlGroupsColumn.add(controlsColumn);
633         
634         controlsColumn.add(new Label("Pressed Effects"));
635
636         controlsColumn.addButton("Enable Pressed Effects", new ActionListener() {
637             public void actionPerformed(ActionEvent e) {
638                 apply(new Applicator() {
639                     public void apply(AbstractButton button) {
640                         button.setPressedEnabled(true);
641                     }
642                 });
643             }
644         });
645         controlsColumn.addButton("Disable Pressed Effects", new ActionListener() {
646             public void actionPerformed(ActionEvent e) {
647                 apply(new Applicator() {
648                     public void apply(AbstractButton button) {
649                         button.setPressedEnabled(false);
650                     }
651                 });
652             }
653         });
654         controlsColumn.addButton("Set Pressed Icon", new ActionListener() {
655             public void actionPerformed(ActionEvent e) {
656                 apply(new Applicator() {
657                     public void apply(AbstractButton button) {
658                         if (button.getIcon() != null) {
659                             button.setPressedIcon(Styles.PRESSED_ICON_LOGO);
660                         }
661                     }
662                 });
663             }
664         });
665         controlsColumn.addButton("Clear Pressed Icon", new ActionListener() {
666             public void actionPerformed(ActionEvent e) {
667                 apply(new Applicator() {
668                     public void apply(AbstractButton button) {
669                         if (button.getIcon() != null) {
670                             button.setPressedIcon(null);
671                         }
672                     }
673                 });
674             }
675         });
676         controlsColumn.addButton("Set Pressed Foreground", new ActionListener() {
677             public void actionPerformed(ActionEvent e) {
678                 final Color color = StyleUtil.randomColor();
679                 apply(new Applicator() {
680                     public void apply(AbstractButton button) {
681                         button.setPressedForeground(color);
682                     }
683                 });
684             }
685         });
686         controlsColumn.addButton("Clear Pressed Foreground", new ActionListener() {
687             public void actionPerformed(ActionEvent e) {
688                 apply(new Applicator() {
689                     public void apply(AbstractButton button) {
690                         button.setPressedForeground(null);
691                     }
692                 });
693             }
694         });
695         controlsColumn.addButton("Set Pressed Background", new ActionListener() {
696             public void actionPerformed(ActionEvent e) {
697                 final Color color = StyleUtil.randomColor();
698                 apply(new Applicator() {
699                     public void apply(AbstractButton button) {
700                         button.setPressedBackground(color);
701                     }
702                 });
703             }
704         });
705         controlsColumn.addButton("Clear Pressed Background", new ActionListener() {
706             public void actionPerformed(ActionEvent e) {
707                 apply(new Applicator() {
708                     public void apply(AbstractButton button) {
709                         button.setPressedBackground(null);
710                     }
711                 });
712             }
713         });
714         controlsColumn.addButton("Set Pressed Font", new ActionListener() {
715             public void actionPerformed(ActionEvent e) {
716                 final Font font = StyleUtil.randomFont();
717                 apply(new Applicator() {
718                     public void apply(AbstractButton button) {
719                         button.setPressedFont(font);
720                     }
721                 });
722             }
723         });
724         controlsColumn.addButton("Clear Pressed Font", new ActionListener() {
725             public void actionPerformed(ActionEvent e) {
726                 apply(new Applicator() {
727                     public void apply(AbstractButton button) {
728                         button.setPressedFont(null);
729                     }
730                 });
731             }
732         });
733         controlsColumn.addButton("Set Pressed Background Image", new ActionListener() {
734             public void actionPerformed(ActionEvent e) {
735                 apply(new Applicator() {
736                     public void apply(AbstractButton button) {
737                         button.setPressedBackgroundImage(Styles.BUTTON_PRESSED_BACKGROUND_IMAGE);
738                     }
739                 });
740             }
741         });
742         controlsColumn.addButton("Clear Pressed Background Image", new ActionListener() {
743             public void actionPerformed(ActionEvent e) {
744                 apply(new Applicator() {
745                     public void apply(AbstractButton button) {
746                         button.setPressedBackgroundImage(null);
747                     }
748                 });
749             }
750         });
751         
752         // Disabled Effect Settings
753

754         controlsColumn = new ButtonColumn();
755         controlGroupsColumn.add(controlsColumn);
756         
757         controlsColumn.add(new Label("Disabled Effects"));
758
759         controlsColumn.addButton("Set Disabled Icon", new ActionListener() {
760             public void actionPerformed(ActionEvent e) {
761                 apply(new Applicator() {
762                     public void apply(AbstractButton button) {
763                         if (button.getIcon() != null) {
764                             button.setDisabledIcon(Styles.DISABLED_ICON_LOGO);
765                         }
766                     }
767                 });
768             }
769         });
770         controlsColumn.addButton("Clear Disabled Icon", new ActionListener() {
771             public void actionPerformed(ActionEvent e) {
772                 apply(new Applicator() {
773                     public void apply(AbstractButton button) {
774                         if (button.getIcon() != null) {
775                             button.setDisabledIcon(null);
776                         }
777                     }
778                 });
779             }
780         });
781         controlsColumn.addButton("Set Disabled Foreground", new ActionListener() {
782             public void actionPerformed(ActionEvent e) {
783                 final Color color = StyleUtil.randomColor();
784                 apply(new Applicator() {
785                     public void apply(AbstractButton button) {
786                         button.setDisabledForeground(color);
787                     }
788                 });
789             }
790         });
791         controlsColumn.addButton("Clear Disabled Foreground", new ActionListener() {
792             public void actionPerformed(ActionEvent e) {
793                 apply(new Applicator() {
794                     public void apply(AbstractButton button) {
795                         button.setDisabledForeground(null);
796                     }
797                 });
798             }
799         });
800         controlsColumn.addButton("Set Disabled Background", new ActionListener() {
801             public void actionPerformed(ActionEvent e) {
802                 final Color color = StyleUtil.randomColor();
803                 apply(new Applicator() {
804                     public void apply(AbstractButton button) {
805                         button.setDisabledBackground(color);
806                     }
807                 });
808             }
809         });
810         controlsColumn.addButton("Clear Disabled Background", new ActionListener() {
811             public void actionPerformed(ActionEvent e) {
812                 apply(new Applicator() {
813                     public void apply(AbstractButton button) {
814                         button.setDisabledBackground(null);
815                     }
816                 });
817             }
818         });
819         controlsColumn.addButton("Set Disabled Font", new ActionListener() {
820             public void actionPerformed(ActionEvent e) {
821                 final Font font = StyleUtil.randomFont();
822                 apply(new Applicator() {
823                     public void apply(AbstractButton button) {
824                         button.setDisabledFont(font);
825                     }
826                 });
827             }
828         });
829         controlsColumn.addButton("Clear Disabled Font", new ActionListener() {
830             public void actionPerformed(ActionEvent e) {
831                 apply(new Applicator() {
832                     public void apply(AbstractButton button) {
833                         button.setDisabledFont(null);
834                     }
835                 });
836             }
837         });
838         controlsColumn.addButton("Set Disabled Background Image", new ActionListener() {
839             public void actionPerformed(ActionEvent e) {
840                 apply(new Applicator() {
841                     public void apply(AbstractButton button) {
842                         button.setDisabledBackgroundImage(Styles.BUTTON_DISABLED_BACKGROUND_IMAGE);
843                     }
844                 });
845             }
846         });
847         controlsColumn.addButton("Clear Disabled Background Image", new ActionListener() {
848             public void actionPerformed(ActionEvent e) {
849                 apply(new Applicator() {
850                     public void apply(AbstractButton button) {
851                         button.setDisabledBackgroundImage(null);
852                     }
853                 });
854             }
855         });
856         
857         // Text Position
858

859         controlsColumn = new ButtonColumn();
860         controlGroupsColumn.add(controlsColumn);
861         
862         controlsColumn.add(new Label("Text Position"));
863
864         controlsColumn.addButton("TextPosition = Default", new ActionListener() {
865             public void actionPerformed(ActionEvent e) {
866                 apply(new Applicator() {
867                     public void apply(AbstractButton button) {
868                         button.setTextPosition(null);
869                     }
870                 });
871             }
872         });
873         controlsColumn.addButton("TextPosition = Top", new ActionListener() {
874             public void actionPerformed(ActionEvent e) {
875                 apply(new Applicator() {
876                     public void apply(AbstractButton button) {
877                         button.setTextPosition(new Alignment(Alignment.DEFAULT, Alignment.TOP));
878                     }
879                 });
880             }
881         });
882         controlsColumn.addButton("TextPosition = Bottom", new ActionListener() {
883             public void actionPerformed(ActionEvent e) {
884                 apply(new Applicator() {
885                     public void apply(AbstractButton button) {
886                         button.setTextPosition(new Alignment(Alignment.DEFAULT, Alignment.BOTTOM));
887                     }
888                 });
889             }
890         });
891         controlsColumn.addButton("TextPosition = Left", new ActionListener() {
892             public void actionPerformed(ActionEvent e) {
893                 apply(new Applicator() {
894                     public void apply(AbstractButton button) {
895                         button.setTextPosition(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
896                     }
897                 });
898             }
899         });
900         controlsColumn.addButton("TextPosition = Right", new ActionListener() {
901             public void actionPerformed(ActionEvent e) {
902                 apply(new Applicator() {
903                     public void apply(AbstractButton button) {
904                         button.setTextPosition(new Alignment(Alignment.RIGHT, Alignment.DEFAULT));
905                     }
906                 });
907             }
908         });
909         controlsColumn.addButton("TextPosition = Leading", new ActionListener() {
910             public void actionPerformed(ActionEvent e) {
911                 apply(new Applicator() {
912                     public void apply(AbstractButton button) {
913                         button.setTextPosition(new Alignment(Alignment.LEADING, Alignment.DEFAULT));
914                     }
915                 });
916             }
917         });
918         controlsColumn.addButton("TextPosition = Trailing", new ActionListener() {
919             public void actionPerformed(ActionEvent e) {
920                 apply(new Applicator() {
921                     public void apply(AbstractButton button) {
922                         button.setTextPosition(new Alignment(Alignment.TRAILING, Alignment.DEFAULT));
923                     }
924                 });
925             }
926         });
927         
928         // Text Alignment
929

930         controlsColumn = new ButtonColumn();
931         controlGroupsColumn.add(controlsColumn);
932         
933         controlsColumn.add(new Label("Text Alignment"));
934
935         controlsColumn.addButton("TextAlignment = Default", new ActionListener() {
936             public void actionPerformed(ActionEvent e) {
937                 apply(new Applicator() {
938                     public void apply(AbstractButton button) {
939                         button.setTextAlignment(null);
940                     }
941                 });
942             }
943         });
944         controlsColumn.addButton("TextAlignment = Top", new ActionListener() {
945             public void actionPerformed(ActionEvent e) {
946                 apply(new Applicator() {
947                     public void apply(AbstractButton button) {
948                         button.setTextAlignment(new Alignment(Alignment.DEFAULT, Alignment.TOP));
949                     }
950                 });
951             }
952         });
953         controlsColumn.addButton("TextAlignment = Center (V)", new ActionListener() {
954             public void actionPerformed(ActionEvent e) {
955                 apply(new Applicator() {
956                     public void apply(AbstractButton button) {
957                         button.setTextAlignment(new Alignment(Alignment.DEFAULT, Alignment.CENTER));
958                     }
959                 });
960             }
961         });
962         controlsColumn.addButton("TextAlignment = Bottom", new ActionListener() {
963             public void actionPerformed(ActionEvent e) {
964                 apply(new Applicator() {
965                     public void apply(AbstractButton button) {
966                         button.setTextAlignment(new Alignment(Alignment.DEFAULT, Alignment.BOTTOM));
967                     }
968                 });
969             }
970         });
971         controlsColumn.addButton("TextAlignment = Left", new ActionListener() {
972             public void actionPerformed(ActionEvent e) {
973                 apply(new Applicator() {
974                     public void apply(AbstractButton button) {
975                         button.setTextAlignment(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
976                     }
977                 });
978             }
979         });
980         controlsColumn.addButton("TextAlignment = Center (H)", new ActionListener() {
981             public void actionPerformed(ActionEvent e) {
982                 apply(new Applicator() {
983                     public void apply(AbstractButton button) {
984                         button.setTextAlignment(new Alignment(Alignment.CENTER, Alignment.DEFAULT));
985                     }
986                 });
987             }
988         });
989         controlsColumn.addButton("TextAlignment = Right", new ActionListener() {
990             public void actionPerformed(ActionEvent e) {
991                 apply(new Applicator() {
992                     public void apply(AbstractButton button) {
993                         button.setTextAlignment(new Alignment(Alignment.RIGHT, Alignment.DEFAULT));
994                     }
995                 });
996             }
997         });
998         controlsColumn.addButton("TextAlignment = Leading", new ActionListener() {
999             public void actionPerformed(ActionEvent e) {
1000                apply(new Applicator() {
1001                    public void apply(AbstractButton button) {
1002                        button.setTextAlignment(new Alignment(Alignment.LEADING, Alignment.DEFAULT));
1003                    }
1004                });
1005            }
1006        });
1007        controlsColumn.addButton("TextAlignment = Trailing", new ActionListener() {
1008            public void actionPerformed(ActionEvent e) {
1009                apply(new Applicator() {
1010                    public void apply(AbstractButton button) {
1011                        button.setTextAlignment(new Alignment(Alignment.TRAILING, Alignment.DEFAULT));
1012                    }
1013                });
1014            }
1015        });
1016        
1017        // Alignment
1018

1019        controlsColumn = new ButtonColumn();
1020        controlGroupsColumn.add(controlsColumn);
1021        
1022        controlsColumn.add(new Label("Alignment"));
1023
1024        controlsColumn.addButton("Alignment = Default", new ActionListener() {
1025            public void actionPerformed(ActionEvent e) {
1026                apply(new Applicator() {
1027                    public void apply(AbstractButton button) {
1028                        button.setAlignment(null);
1029                    }
1030                });
1031            }
1032        });
1033        controlsColumn.addButton("Alignment = Left", new ActionListener() {
1034            public void actionPerformed(ActionEvent e) {
1035                apply(new Applicator() {
1036                    public void apply(AbstractButton button) {
1037                        button.setAlignment(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
1038                    }
1039                });
1040            }
1041        });
1042        controlsColumn.addButton("Alignment = Center (H)", new ActionListener() {
1043            public void actionPerformed(ActionEvent e) {
1044                apply(new Applicator() {
1045                    public void apply(AbstractButton button) {
1046                        button.setAlignment(new Alignment(Alignment.CENTER, Alignment.DEFAULT));
1047                    }
1048                });
1049            }
1050        });
1051        controlsColumn.addButton("Alignment = Right", new ActionListener() {
1052            public void actionPerformed(ActionEvent e) {
1053                apply(new Applicator() {
1054                    public void apply(AbstractButton button) {
1055                        button.setAlignment(new Alignment(Alignment.RIGHT, Alignment.DEFAULT));
1056                    }
1057                });
1058            }
1059        });
1060        controlsColumn.addButton("Alignment = Leading", new ActionListener() {
1061            public void actionPerformed(ActionEvent e) {
1062                apply(new Applicator() {
1063                    public void apply(AbstractButton button) {
1064                        button.setAlignment(new Alignment(Alignment.LEADING, Alignment.DEFAULT));
1065                    }
1066                });
1067            }
1068        });
1069        controlsColumn.addButton("Alignment = Trailing", new ActionListener() {
1070            public void actionPerformed(ActionEvent e) {
1071                apply(new Applicator() {
1072                    public void apply(AbstractButton button) {
1073                        button.setAlignment(new Alignment(Alignment.TRAILING, Alignment.DEFAULT));
1074                    }
1075                });
1076            }
1077        });
1078        
1079        // Icon/Text Margin
1080

1081        controlsColumn = new ButtonColumn();
1082        controlGroupsColumn.add(controlsColumn);
1083        
1084        controlsColumn.add(new Label("Icon/Text Margin"));
1085
1086        controlsColumn.addButton("IconTextMargin = default", new ActionListener() {
1087            public void actionPerformed(ActionEvent e) {
1088                apply(new Applicator() {
1089                    public void apply(AbstractButton button) {
1090                        button.setIconTextMargin(null);
1091                    }
1092                });
1093            }
1094        });
1095        controlsColumn.addButton("IconTextMargin = 0px", new ActionListener() {
1096            public void actionPerformed(ActionEvent e) {
1097                apply(new Applicator() {
1098                    public void apply(AbstractButton button) {
1099                        button.setIconTextMargin(new Extent(0));
1100                    }
1101                });
1102            }
1103        });
1104        controlsColumn.addButton("IconTextMargin = 1px", new ActionListener() {
1105            public void actionPerformed(ActionEvent e) {
1106                apply(new Applicator() {
1107                    public void apply(AbstractButton button) {
1108                        button.setIconTextMargin(new Extent(1));
1109                    }
1110                });
1111            }
1112        });
1113        controlsColumn.addButton("IconTextMargin = 2px", new ActionListener() {
1114            public void actionPerformed(ActionEvent e) {
1115                apply(new Applicator() {
1116                    public void apply(AbstractButton button) {
1117                        button.setIconTextMargin(new Extent(2));
1118                    }
1119                });
1120            }
1121        });
1122        controlsColumn.addButton("IconTextMargin = 10px", new ActionListener() {
1123            public void actionPerformed(ActionEvent e) {
1124                apply(new Applicator() {
1125                    public void apply(AbstractButton button) {
1126                        button.setIconTextMargin(new Extent(10));
1127                    }
1128                });
1129            }
1130        });
1131        controlsColumn.addButton("IconTextMargin = 1in", new ActionListener() {
1132            public void actionPerformed(ActionEvent e) {
1133                apply(new Applicator() {
1134                    public void apply(AbstractButton button) {
1135                        button.setIconTextMargin(new Extent(1, Extent.IN));
1136                    }
1137                });
1138            }
1139        });
1140
1141        // Create 'ToggleButton Controls Group'
1142

1143        controlsColumn = new ButtonColumn();
1144        controlGroupsColumn.add(controlsColumn);
1145        
1146        controlsColumn.add(new Label("General ToggleButton Controls"));
1147        
1148        controlsColumn.addButton("Selected = False", new ActionListener() {
1149            public void actionPerformed(ActionEvent e) {
1150                apply(new Applicator() {
1151                    public void apply(AbstractButton button) {
1152                        if (button instanceof ToggleButton) {
1153                            ((ToggleButton) button).setSelected(false);
1154                        }
1155                    }
1156                });
1157            }
1158        });
1159        controlsColumn.addButton("Selected = True", new ActionListener() {
1160            public void actionPerformed(ActionEvent e) {
1161                apply(new Applicator() {
1162                    public void apply(AbstractButton button) {
1163                        if (button instanceof ToggleButton) {
1164                            ((ToggleButton) button).setSelected(true);
1165                        }
1166                    }
1167                });
1168            }
1169        });
1170        controlsColumn.addButton("Set Custom State Icons", new ActionListener() {
1171            public void actionPerformed(ActionEvent e) {
1172                apply(new Applicator() {
1173                    public void apply(AbstractButton button) {
1174                        if (button instanceof ToggleButton) {
1175                            ToggleButton toggleButton = (ToggleButton) button;
1176                            toggleButton.setStateIcon(Styles.RG_STATE_ICON);
1177                            toggleButton.setSelectedStateIcon(Styles.RG_SELECTED_STATE_ICON);
1178                            toggleButton.setPressedStateIcon(Styles.RG_PRESSED_STATE_ICON);
1179                            toggleButton.setPressedSelectedStateIcon(Styles.RG_PRESSED_SELECTED_STATE_ICON);
1180                            toggleButton.setRolloverStateIcon(Styles.RG_ROLLOVER_STATE_ICON);
1181                            toggleButton.setRolloverSelectedStateIcon(Styles.RG_ROLLOVER_SELECTED_STATE_ICON);
1182                        }
1183                    }
1184                });
1185            }
1186        });
1187        controlsColumn.addButton("Clear Custom State Icons", new ActionListener() {
1188            public void actionPerformed(ActionEvent e) {
1189                apply(new Applicator() {
1190                    public void apply(AbstractButton button) {
1191                        if (button instanceof ToggleButton) {
1192                            ToggleButton toggleButton = (ToggleButton) button;
1193                            toggleButton.setStateIcon(null);
1194                            toggleButton.setSelectedStateIcon(null);
1195                            toggleButton.setPressedStateIcon(null);
1196                            toggleButton.setPressedSelectedStateIcon(null);
1197                            toggleButton.setRolloverStateIcon(null);
1198                            toggleButton.setRolloverSelectedStateIcon(null);
1199                        }
1200                    }
1201                });
1202            }
1203        });
1204        
1205        // ToggleButton State Position
1206

1207        controlsColumn = new ButtonColumn();
1208        controlGroupsColumn.add(controlsColumn);
1209        
1210        controlsColumn.add(new Label("ToggleButton State Position"));
1211        
1212        controlsColumn.addButton("StatePosition = Default", new ActionListener() {
1213            public void actionPerformed(ActionEvent e) {
1214                apply(new Applicator() {
1215                    public void apply(AbstractButton button) {
1216                        if (button instanceof ToggleButton) {
1217                            ((ToggleButton) button).setStatePosition(null);
1218                        }
1219                    }
1220                });
1221            }
1222        });
1223        controlsColumn.addButton("StatePosition = Top", new ActionListener() {
1224            public void actionPerformed(ActionEvent e) {
1225                apply(new Applicator() {
1226                    public void apply(AbstractButton button) {
1227                        if (button instanceof ToggleButton) {
1228                            ((ToggleButton) button).setStatePosition(new Alignment(Alignment.DEFAULT, Alignment.TOP));
1229                        }
1230                    }
1231                });
1232            }
1233        });
1234        controlsColumn.addButton("StatePosition = Bottom", new ActionListener() {
1235            public void actionPerformed(ActionEvent e) {
1236                apply(new Applicator() {
1237                    public void apply(AbstractButton button) {
1238                        if (button instanceof ToggleButton) {
1239                            ((ToggleButton) button).setStatePosition(new Alignment(Alignment.DEFAULT, Alignment.BOTTOM));
1240                        }
1241                    }
1242                });
1243            }
1244        });
1245        controlsColumn.addButton("StatePosition = Left", new ActionListener() {
1246            public void actionPerformed(ActionEvent e) {
1247                apply(new Applicator() {
1248                    public void apply(AbstractButton button) {
1249                        if (button instanceof ToggleButton) {
1250                            ((ToggleButton) button).setStatePosition(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
1251                        }
1252                    }
1253                });
1254            }
1255        });
1256        controlsColumn.addButton("StatePosition = Right", new ActionListener() {
1257            public void actionPerformed(ActionEvent e) {
1258                apply(new Applicator() {
1259                    public void apply(AbstractButton button) {
1260                        if (button instanceof ToggleButton) {
1261                            ((ToggleButton) button).setStatePosition(new Alignment(Alignment.RIGHT, Alignment.DEFAULT));
1262                        }
1263                    }
1264                });
1265            }
1266        });
1267        controlsColumn.addButton("StatePosition = Leading", new ActionListener() {
1268            public void actionPerformed(ActionEvent e) {
1269                apply(new Applicator() {
1270                    public void apply(AbstractButton button) {
1271                        if (button instanceof ToggleButton) {
1272                            ((ToggleButton) button).setStatePosition(new Alignment(Alignment.LEADING, Alignment.DEFAULT));
1273                        }
1274                    }
1275                });
1276            }
1277        });
1278        controlsColumn.addButton("StatePosition = Trailing", new ActionListener() {
1279            public void actionPerformed(ActionEvent e) {
1280                apply(new Applicator() {
1281                    public void apply(AbstractButton button) {
1282                        if (button instanceof ToggleButton) {
1283                            ((ToggleButton) button).setStatePosition(new Alignment(Alignment.TRAILING, Alignment.DEFAULT));
1284                        }
1285                    }
1286                });
1287            }
1288        });
1289        
1290        // ToggleButton State Alignment
1291

1292        controlsColumn = new ButtonColumn();
1293        controlGroupsColumn.add(controlsColumn);
1294        
1295        controlsColumn.add(new Label("ToggleButton State Alignment"));
1296        
1297        controlsColumn.addButton("StateAlignment = Default", new ActionListener() {
1298            public void actionPerformed(ActionEvent e) {
1299                apply(new Applicator() {
1300                    public void apply(AbstractButton button) {
1301                        if (button instanceof ToggleButton) {
1302                            ((ToggleButton) button).setStateAlignment(null);
1303                        }
1304                    }
1305                });
1306            }
1307        });
1308        controlsColumn.addButton("StateAlignment = Top", new ActionListener() {
1309            public void actionPerformed(ActionEvent e) {
1310                apply(new Applicator() {
1311                    public void apply(AbstractButton button) {
1312                        if (button instanceof ToggleButton) {
1313                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.DEFAULT, Alignment.TOP));
1314                        }
1315                    }
1316                });
1317            }
1318        });
1319        controlsColumn.addButton("StateAlignment = Center (V)", new ActionListener() {
1320            public void actionPerformed(ActionEvent e) {
1321                apply(new Applicator() {
1322                    public void apply(AbstractButton button) {
1323                        if (button instanceof ToggleButton) {
1324                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.DEFAULT, Alignment.CENTER));
1325                        }
1326                    }
1327                });
1328            }
1329        });
1330        controlsColumn.addButton("StateAlignment = Bottom", new ActionListener() {
1331            public void actionPerformed(ActionEvent e) {
1332                apply(new Applicator() {
1333                    public void apply(AbstractButton button) {
1334                        if (button instanceof ToggleButton) {
1335                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.DEFAULT, Alignment.BOTTOM));
1336                        }
1337                    }
1338                });
1339            }
1340        });
1341        controlsColumn.addButton("StateAlignment = Left", new ActionListener() {
1342            public void actionPerformed(ActionEvent e) {
1343                apply(new Applicator() {
1344                    public void apply(AbstractButton button) {
1345                        if (button instanceof ToggleButton) {
1346                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
1347                        }
1348                    }
1349                });
1350            }
1351        });
1352        controlsColumn.addButton("StateAlignment = Center (H)", new ActionListener() {
1353            public void actionPerformed(ActionEvent e) {
1354                apply(new Applicator() {
1355                    public void apply(AbstractButton button) {
1356                        if (button instanceof ToggleButton) {
1357                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.CENTER, Alignment.DEFAULT));
1358                        }
1359                    }
1360                });
1361            }
1362        });
1363        controlsColumn.addButton("StateAlignment = Right", new ActionListener() {
1364            public void actionPerformed(ActionEvent e) {
1365                apply(new Applicator() {
1366                    public void apply(AbstractButton button) {
1367                        if (button instanceof ToggleButton) {
1368                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.RIGHT, Alignment.DEFAULT));
1369                        }
1370                    }
1371                });
1372            }
1373        });
1374        controlsColumn.addButton("StateAlignment = Leading", new ActionListener() {
1375            public void actionPerformed(ActionEvent e) {
1376                apply(new Applicator() {
1377                    public void apply(AbstractButton button) {
1378                        if (button instanceof ToggleButton) {
1379                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.LEADING, Alignment.DEFAULT));
1380                        }
1381                    }
1382                });
1383            }
1384        });
1385        controlsColumn.addButton("StateAlignment = Trailing", new ActionListener() {
1386            public void actionPerformed(ActionEvent e) {
1387                apply(new Applicator() {
1388                    public void apply(AbstractButton button) {
1389                        if (button instanceof ToggleButton) {
1390                            ((ToggleButton) button).setStateAlignment(new Alignment(Alignment.TRAILING, Alignment.DEFAULT));
1391                        }
1392                    }
1393                });
1394            }
1395        });
1396
1397        
1398        // State Margin
1399

1400        controlsColumn = new ButtonColumn();
1401        controlGroupsColumn.add(controlsColumn);
1402        
1403        controlsColumn.add(new Label("State Margin"));
1404
1405        controlsColumn.addButton("StateMargin = default", new ActionListener() {
1406            public void actionPerformed(ActionEvent e) {
1407                apply(new Applicator() {
1408                    public void apply(AbstractButton button) {
1409                        if (button instanceof ToggleButton) {
1410                            ((ToggleButton) button).setStateMargin(null);
1411                        }
1412                    }
1413                });
1414            }
1415        });
1416        controlsColumn.addButton("StateMargin = 0px", new ActionListener() {
1417            public void actionPerformed(ActionEvent e) {
1418                apply(new Applicator() {
1419                    public void apply(AbstractButton button) {
1420                        if (button instanceof ToggleButton) {
1421                            ((ToggleButton) button).setStateMargin(new Extent(0));
1422                        }
1423                    }
1424                });
1425            }
1426        });
1427        controlsColumn.addButton("StateMargin = 1px", new ActionListener() {
1428            public void actionPerformed(ActionEvent e) {
1429                apply(new Applicator() {
1430                    public void apply(AbstractButton button) {
1431                        if (button instanceof ToggleButton) {
1432                            ((ToggleButton) button).setStateMargin(new Extent(1));
1433                        }
1434                    }
1435                });
1436            }
1437        });
1438        controlsColumn.addButton("StateMargin = 2px", new ActionListener() {
1439            public void actionPerformed(ActionEvent e) {
1440                apply(new Applicator() {
1441                    public void apply(AbstractButton button) {
1442                        if (button instanceof ToggleButton) {
1443                            ((ToggleButton) button).setStateMargin(new Extent(2));
1444                        }
1445                    }
1446                });
1447            }
1448        });
1449        controlsColumn.addButton("StateMargin = 10px", new ActionListener() {
1450            public void actionPerformed(ActionEvent e) {
1451                apply(new Applicator() {
1452                    public void apply(AbstractButton button) {
1453                        if (button instanceof ToggleButton) {
1454                            ((ToggleButton) button).setStateMargin(new Extent(10));
1455                        }
1456                    }
1457                });
1458            }
1459        });
1460        controlsColumn.addButton("StateMargin = 1in", new ActionListener() {
1461            public void actionPerformed(ActionEvent e) {
1462                apply(new Applicator() {
1463                    public void apply(AbstractButton button) {
1464                        if (button instanceof ToggleButton) {
1465                            ((ToggleButton) button).setStateMargin(new Extent(1, Extent.IN));
1466                        }
1467                    }
1468                });
1469            }
1470        });
1471
1472        // Localization
1473

1474        controlsColumn = new ButtonColumn();
1475        controlGroupsColumn.add(controlsColumn);
1476        
1477        controlsColumn.add(new Label("Localization"));
1478        
1479        controlsColumn.addButton("Locale = null", new ActionListener() {
1480            public void actionPerformed(ActionEvent e) {
1481                apply(new Applicator() {
1482                    public void apply(AbstractButton button) {
1483                        button.setLocale(null);
1484                    }
1485                });
1486            }
1487        });
1488        controlsColumn.addButton("Locale = US", new ActionListener() {
1489            public void actionPerformed(ActionEvent e) {
1490                apply(new Applicator() {
1491                    public void apply(AbstractButton button) {
1492                        button.setLocale(Locale.US);
1493                    }
1494                });
1495            }
1496        });
1497        controlsColumn.addButton("Locale = HEBREW (RTL)", new ActionListener() {
1498            public void actionPerformed(ActionEvent e) {
1499                apply(new Applicator() {
1500                    public void apply(AbstractButton button) {
1501                        button.setLocale(new Locale JavaDoc("iw"));
1502                    }
1503                });
1504            }
1505        });
1506        controlsColumn.addButton("LayoutDirection = null", new ActionListener() {
1507            public void actionPerformed(ActionEvent e) {
1508                apply(new Applicator() {
1509                    public void apply(AbstractButton button) {
1510                        button.setLayoutDirection(null);
1511                    }
1512                });
1513            }
1514        });
1515        controlsColumn.addButton("LayoutDirection = LTR", new ActionListener() {
1516            public void actionPerformed(ActionEvent e) {
1517                apply(new Applicator() {
1518                    public void apply(AbstractButton button) {
1519                        button.setLayoutDirection(LayoutDirection.LTR);
1520                    }
1521                });
1522            }
1523        });
1524        controlsColumn.addButton("LayoutDirection = RTL", new ActionListener() {
1525            public void actionPerformed(ActionEvent e) {
1526                apply(new Applicator() {
1527                    public void apply(AbstractButton button) {
1528                        button.setLayoutDirection(LayoutDirection.RTL);
1529                    }
1530                });
1531            }
1532        });
1533    }
1534    
1535    public void apply(Applicator applicator) {
1536        AbstractButton[] buttons = (AbstractButton[]) buttonList.toArray(new AbstractButton[buttonList.size()]);
1537        for (int i = 0; i < buttons.length; ++i) {
1538            applicator.apply(buttons[i]);
1539        }
1540    }
1541}
1542
Popular Tags