Source Code Cross Referenced for ButtonsPanel.java in  » Swing-Library » substance-look-feel » test » check » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » substance look feel » test.check 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:        package test.check;
031:
032:        import java.awt.*;
033:        import java.util.Map;
034:
035:        import javax.swing.*;
036:
037:        import org.jvnet.lafwidget.LafWidget;
038:        import org.jvnet.lafwidget.utils.LafConstants.AnimationKind;
039:        import org.jvnet.substance.SubstanceLookAndFeel;
040:        import org.jvnet.substance.border.BorderPainterInfo;
041:        import org.jvnet.substance.button.ButtonShaperInfo;
042:        import org.jvnet.substance.painter.GradientPainterInfo;
043:        import org.jvnet.substance.theme.*;
044:        import org.jvnet.substance.utils.SubstanceConstants.FocusKind;
045:        import org.jvnet.substance.utils.SubstanceConstants.Side;
046:
047:        import test.Check;
048:        import test.check.command.*;
049:
050:        import com.jgoodies.forms.builder.DefaultFormBuilder;
051:        import com.jgoodies.forms.layout.FormLayout;
052:
053:        /**
054:         * Test application panel for testing {@link JButton}, {@link JToggleButton},
055:         * {@link JRadioButton} and {@link JCheckBox} components.
056:         * 
057:         * @author Kirill Grouchnikov
058:         */
059:        public class ButtonsPanel extends JPanel {
060:            /**
061:             * The default button.
062:             */
063:            public JButton defaultButton;
064:
065:            // /**
066:            // * A configure command that disables the specified button.
067:            // *
068:            // * @author Kirill Grouchnikov
069:            // */
070:            // private class DisableCommand implements
071:            // ConfigurationCommand<AbstractButton> {
072:            // /*
073:            // * (non-Javadoc)
074:            // *
075:            // * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
076:            // */
077:            // public void configure(AbstractButton ab) {
078:            // ab.setEnabled(false);
079:            // }
080:            // }
081:
082:            // /**
083:            // * A configure command that selects the specified button.
084:            // *
085:            // * @author Kirill Grouchnikov
086:            // */
087:            // private class SelectCommand implements
088:            // ConfigurationCommand<AbstractButton> {
089:            // /*
090:            // * (non-Javadoc)
091:            // *
092:            // * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
093:            // */
094:            // public void configure(AbstractButton ab) {
095:            // if (ab instanceof JButton)
096:            // return;
097:            // ab.setSelected(true);
098:            // }
099:            // }
100:
101:            /**
102:             * A configure command that sets a specified theme on the specified button.
103:             * 
104:             * @author Kirill Grouchnikov
105:             */
106:            private class ThemeCommand implements 
107:                    ConfigurationCommand<AbstractButton> {
108:                /**
109:                 * Theme object.
110:                 */
111:                private Object themeObj;
112:
113:                /**
114:                 * Creates the theme configuration command.
115:                 * 
116:                 * @param themeObj
117:                 *            Theme object.
118:                 */
119:                public ThemeCommand(Object themeObj) {
120:                    this .themeObj = themeObj;
121:                }
122:
123:                /*
124:                 * (non-Javadoc)
125:                 * 
126:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
127:                 */
128:                public void configure(AbstractButton ab) {
129:                    ab.putClientProperty(SubstanceLookAndFeel.THEME_PROPERTY,
130:                            themeObj);
131:                }
132:            }
133:
134:            /**
135:             * A configure command that applies the specified button shaper on the
136:             * specified button.
137:             * 
138:             * @author Kirill Grouchnikov
139:             */
140:            private class ShaperCommand implements 
141:                    ConfigurationCommand<AbstractButton> {
142:                /**
143:                 * Button shaper object.
144:                 */
145:                private Object shaperObj;
146:
147:                /**
148:                 * Creates the button shaper configuration command.
149:                 * 
150:                 * @param shaperObj
151:                 *            Button shaper object.
152:                 */
153:                public ShaperCommand(Object shaperObj) {
154:                    this .shaperObj = shaperObj;
155:                }
156:
157:                /*
158:                 * (non-Javadoc)
159:                 * 
160:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
161:                 */
162:                public void configure(AbstractButton ab) {
163:                    ab.putClientProperty(
164:                            SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
165:                            shaperObj);
166:                }
167:            }
168:
169:            /**
170:             * A configure command that sets the specified gradient painter on the
171:             * specified button.
172:             * 
173:             * @author Kirill Grouchnikov
174:             */
175:            private class GradientPainterCommand implements 
176:                    ConfigurationCommand<AbstractButton> {
177:                /**
178:                 * Gradient painter object.
179:                 */
180:                private Object painterObj;
181:
182:                /**
183:                 * Creates the gradient painter configuration command.
184:                 * 
185:                 * @param painterObj
186:                 *            Gradient painter object.
187:                 */
188:                public GradientPainterCommand(Object painterObj) {
189:                    this .painterObj = painterObj;
190:                }
191:
192:                /*
193:                 * (non-Javadoc)
194:                 * 
195:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
196:                 */
197:                public void configure(AbstractButton ab) {
198:                    ab.putClientProperty(
199:                            SubstanceLookAndFeel.GRADIENT_PAINTER_PROPERTY,
200:                            painterObj);
201:                }
202:            }
203:
204:            /**
205:             * A configure command that sets the specified border painter on the
206:             * specified button.
207:             * 
208:             * @author Kirill Grouchnikov
209:             */
210:            private class BorderPainterCommand implements 
211:                    ConfigurationCommand<AbstractButton> {
212:                /**
213:                 * Gradient painter object.
214:                 */
215:                private Object painterObj;
216:
217:                /**
218:                 * Creates the gradient painter configuration command.
219:                 * 
220:                 * @param painterObj
221:                 *            Gradient painter object.
222:                 */
223:                public BorderPainterCommand(Object painterObj) {
224:                    this .painterObj = painterObj;
225:                }
226:
227:                /*
228:                 * (non-Javadoc)
229:                 * 
230:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
231:                 */
232:                public void configure(AbstractButton ab) {
233:                    ab.putClientProperty(
234:                            SubstanceLookAndFeel.BORDER_PAINTER_PROPERTY,
235:                            painterObj);
236:                }
237:            }
238:
239:            /**
240:             * A configure command that marks the specified button to always be painted
241:             * in active state.
242:             * 
243:             * @author Kirill Grouchnikov
244:             */
245:            private class PaintActiveCommand implements 
246:                    ConfigurationCommand<AbstractButton> {
247:                /*
248:                 * (non-Javadoc)
249:                 * 
250:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
251:                 */
252:                public void configure(AbstractButton ab) {
253:                    ab.putClientProperty(
254:                            SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY,
255:                            Boolean.TRUE);
256:                }
257:            }
258:
259:            /**
260:             * A configure command that removes the focus painting from the specified
261:             * button.
262:             * 
263:             * @author Kirill Grouchnikov
264:             */
265:            private class NoFocusCommand implements 
266:                    ConfigurationCommand<AbstractButton> {
267:                /*
268:                 * (non-Javadoc)
269:                 * 
270:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
271:                 */
272:                public void configure(AbstractButton ab) {
273:                    ab.setFocusPainted(false);
274:                }
275:            }
276:
277:            /**
278:             * A configure command that sets the specified focus painting kind the
279:             * specified button.
280:             * 
281:             * @author Kirill Grouchnikov
282:             */
283:            private class FocusKindCommand implements 
284:                    ConfigurationCommand<AbstractButton> {
285:                /**
286:                 * Focus painting kind.
287:                 */
288:                private FocusKind focusKind;
289:
290:                /**
291:                 * Creates the focus painting configuration command.
292:                 * 
293:                 * @param focusKind
294:                 *            Focus painting kind.
295:                 */
296:                public FocusKindCommand(FocusKind focusKind) {
297:                    this .focusKind = focusKind;
298:                }
299:
300:                /*
301:                 * (non-Javadoc)
302:                 * 
303:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
304:                 */
305:                public void configure(AbstractButton ab) {
306:                    ab.putClientProperty(SubstanceLookAndFeel.FOCUS_KIND,
307:                            focusKind);
308:                }
309:            }
310:
311:            /**
312:             * A configure command that sets the specified animation kind the specified
313:             * button.
314:             * 
315:             * @author Kirill Grouchnikov
316:             */
317:            private class AnimationKindCommand implements 
318:                    ConfigurationCommand<AbstractButton> {
319:                /**
320:                 * Animation kind.
321:                 */
322:                private AnimationKind animationKind;
323:
324:                /**
325:                 * Creates a new animation configuration command.
326:                 * 
327:                 * @param animationKind
328:                 *            Animation kind.
329:                 */
330:                public AnimationKindCommand(AnimationKind animationKind) {
331:                    this .animationKind = animationKind;
332:                }
333:
334:                /*
335:                 * (non-Javadoc)
336:                 * 
337:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
338:                 */
339:                public void configure(AbstractButton ab) {
340:                    ab.putClientProperty(LafWidget.ANIMATION_KIND,
341:                            animationKind);
342:                }
343:            }
344:
345:            /**
346:             * A configure command that marks the specified button to not have minimum
347:             * size.
348:             * 
349:             * @author Kirill Grouchnikov
350:             */
351:            private class NoMinSizeCommand implements 
352:                    ConfigurationCommand<AbstractButton> {
353:                /*
354:                 * (non-Javadoc)
355:                 * 
356:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
357:                 */
358:                public void configure(AbstractButton ab) {
359:                    ab.putClientProperty(
360:                            SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY,
361:                            Boolean.TRUE);
362:                }
363:            }
364:
365:            /**
366:             * A configure command that sets a 5-pixel margin on the specified button.
367:             * 
368:             * @author Kirill Grouchnikov
369:             */
370:            private class MarginCommand implements 
371:                    ConfigurationCommand<AbstractButton> {
372:                /*
373:                 * (non-Javadoc)
374:                 * 
375:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
376:                 */
377:                public void configure(AbstractButton ab) {
378:                    ab.setMargin(new Insets(5, 5, 5, 5));
379:                }
380:            }
381:
382:            /**
383:             * A configure command that sets straight sides on the specified button.
384:             * 
385:             * @author Kirill Grouchnikov
386:             */
387:            private class StraightSideCommand implements 
388:                    ConfigurationCommand<AbstractButton> {
389:                /**
390:                 * Straight sides object.
391:                 */
392:                private Object sideObj;
393:
394:                /**
395:                 * Creates a straight side configuration command.
396:                 * 
397:                 * @param sideObj
398:                 *            Straight side object.
399:                 */
400:                public StraightSideCommand(Object sideObj) {
401:                    this .sideObj = sideObj;
402:                }
403:
404:                /*
405:                 * (non-Javadoc)
406:                 * 
407:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
408:                 */
409:                public void configure(AbstractButton ab) {
410:                    ab.putClientProperty(
411:                            SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
412:                            this .sideObj);
413:                }
414:            }
415:
416:            /**
417:             * A configure command that sets open sides on the specified button.
418:             * 
419:             * @author Kirill Grouchnikov
420:             */
421:            private class OpenSideCommand implements 
422:                    ConfigurationCommand<AbstractButton> {
423:                /**
424:                 * Open sides object.
425:                 */
426:                private Object sideObj;
427:
428:                /**
429:                 * Creates an open side configuration command.
430:                 * 
431:                 * @param sideObj
432:                 *            Open side object.
433:                 */
434:                public OpenSideCommand(Object sideObj) {
435:                    this .sideObj = sideObj;
436:                }
437:
438:                /*
439:                 * (non-Javadoc)
440:                 * 
441:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
442:                 */
443:                public void configure(AbstractButton ab) {
444:                    ab.putClientProperty(
445:                            SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY,
446:                            this .sideObj);
447:                }
448:            }
449:
450:            /**
451:             * A configure command that sets the specified text on the specified button.
452:             * 
453:             * @author Kirill Grouchnikov
454:             */
455:            private class TextCommand implements 
456:                    ConfigurationCommand<AbstractButton> {
457:                /**
458:                 * Text to set.
459:                 */
460:                private String text;
461:
462:                /**
463:                 * Creates a text configuration command.
464:                 * 
465:                 * @param text
466:                 *            Text to set.
467:                 */
468:                public TextCommand(String text) {
469:                    this .text = text;
470:                }
471:
472:                /*
473:                 * (non-Javadoc)
474:                 * 
475:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
476:                 */
477:                public void configure(AbstractButton ab) {
478:                    ab.setText(this .text);
479:                }
480:            }
481:
482:            /**
483:             * A configure command that sets the specified tooltip text on the specified
484:             * button.
485:             * 
486:             * @author Kirill Grouchnikov
487:             */
488:            private class TooltipTextCommand implements 
489:                    ConfigurationCommand<AbstractButton> {
490:                /**
491:                 * Tooltip text to set.
492:                 */
493:                private String tooltipText;
494:
495:                /**
496:                 * Creates a tooltip text configuration command.
497:                 * 
498:                 * @param tooltipText
499:                 *            Tooltip text to set.
500:                 */
501:                public TooltipTextCommand(String tooltipText) {
502:                    this .tooltipText = tooltipText;
503:                }
504:
505:                /*
506:                 * (non-Javadoc)
507:                 * 
508:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
509:                 */
510:                public void configure(AbstractButton ab) {
511:                    ab.setToolTipText(this .tooltipText);
512:                }
513:            }
514:
515:            /**
516:             * A configure command that sets a popup menu handler on the specified
517:             * button.
518:             * 
519:             * @author Kirill Grouchnikov
520:             */
521:            private class PopupMenuCommand implements 
522:                    ConfigurationCommand<AbstractButton> {
523:                /*
524:                 * (non-Javadoc)
525:                 * 
526:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
527:                 */
528:                public void configure(AbstractButton ab) {
529:                    ab.addMouseListener(new MousePopupListener(ab));
530:                }
531:            }
532:
533:            /**
534:             * A configure command that sets the specified font on the specified button.
535:             * 
536:             * @author Kirill Grouchnikov
537:             */
538:            private class FontCommand implements 
539:                    ConfigurationCommand<AbstractButton> {
540:                /**
541:                 * Font to set.
542:                 */
543:                private Font font;
544:
545:                /**
546:                 * Creates a font configuration command.
547:                 * 
548:                 * @param font
549:                 *            Font to set.
550:                 */
551:                public FontCommand(Font font) {
552:                    this .font = font;
553:                }
554:
555:                /*
556:                 * (non-Javadoc)
557:                 * 
558:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
559:                 */
560:                public void configure(AbstractButton ab) {
561:                    ab.setFont(this .font);
562:                }
563:            }
564:
565:            /**
566:             * A configure command that sets the specified icon on the specified button.
567:             * 
568:             * @author Kirill Grouchnikov
569:             */
570:            private class IconCommand implements 
571:                    ConfigurationCommand<AbstractButton> {
572:                /**
573:                 * Icon to set.
574:                 */
575:                private Icon icon;
576:
577:                /**
578:                 * Creates an icon configuration command.
579:                 * 
580:                 * @param icon
581:                 *            Icon to set.
582:                 */
583:                public IconCommand(Icon icon) {
584:                    this .icon = icon;
585:                }
586:
587:                /*
588:                 * (non-Javadoc)
589:                 * 
590:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
591:                 */
592:                public void configure(AbstractButton ab) {
593:                    if ((ab instanceof  JRadioButton)
594:                            || (ab instanceof  JCheckBox))
595:                        return;
596:                    ab.setIcon(this .icon);
597:                }
598:            }
599:
600:            /**
601:             * A configure command that marks the button to not have content area
602:             * filled.
603:             * 
604:             * @author Kirill Grouchnikov
605:             */
606:            private class NoContentAreaFilledCommand implements 
607:                    ConfigurationCommand<AbstractButton> {
608:                /*
609:                 * (non-Javadoc)
610:                 * 
611:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
612:                 */
613:                public void configure(AbstractButton ab) {
614:                    ab.setContentAreaFilled(false);
615:                }
616:            }
617:
618:            /**
619:             * A configure command that marks the button to not have border painted.
620:             * 
621:             * @author Kirill Grouchnikov
622:             */
623:            private class NoBorderPaintedCommand implements 
624:                    ConfigurationCommand<AbstractButton> {
625:                /*
626:                 * (non-Javadoc)
627:                 * 
628:                 * @see test.check.ConfigurationCommand#invoke(java.lang.Object)
629:                 */
630:                public void configure(AbstractButton ab) {
631:                    ab.setBorderPainted(false);
632:                }
633:            }
634:
635:            /**
636:             * Returns a row of buttons, consisting of {@link JButton},
637:             * {@link JToggleButton}, {@link JCheckBox} and {@link JRadioButton} in
638:             * default states.
639:             * 
640:             * @return A row of buttons, consisting of {@link JButton},
641:             *         {@link JToggleButton}, {@link JCheckBox} and
642:             *         {@link JRadioButton} in default states.
643:             */
644:            private AbstractButton[] getRow() {
645:                AbstractButton[] result = new AbstractButton[4];
646:                result[0] = new JButton("sample");
647:                result[0].setName("Button " + rowCount);
648:                result[1] = new JToggleButton("sample");
649:                result[1].setName("Toggle " + rowCount);
650:                result[2] = new JCheckBox("sample");
651:                result[2].setName("Check " + rowCount);
652:                result[3] = new JRadioButton("sample");
653:                result[3].setName("Radio " + rowCount);
654:                rowCount++;
655:                return result;
656:            }
657:
658:            private int rowCount = 0;
659:
660:            /**
661:             * Adds a row of buttons configured with the specified text, icon and
662:             * configuration command.
663:             * 
664:             * @param builder
665:             *            Form builder.
666:             * @param label
667:             *            Text to set.
668:             * @param icon
669:             *            Icon to set.
670:             * @param cmd
671:             *            Configuration command to apply.
672:             */
673:            private void addRow(DefaultFormBuilder builder, String label,
674:                    Icon icon, ConfigurationCommand<? super  AbstractButton> cmd) {
675:                AbstractButton[] row = this .getRow();
676:                if (cmd != null) {
677:                    for (AbstractButton ab : row) {
678:                        cmd.configure(ab);
679:                    }
680:                }
681:
682:                JLabel jl = new JLabel(label);
683:                if (icon != null)
684:                    jl.setIcon(icon);
685:                builder.append(jl);
686:                for (AbstractButton ab : row)
687:                    builder.append(ab);
688:            }
689:
690:            /**
691:             * Creates a new button panel.
692:             */
693:            @SuppressWarnings("unchecked")
694:            public ButtonsPanel() {
695:                this .setLayout(new BorderLayout());
696:
697:                FormLayout lm = new FormLayout(
698:                        "right:pref, 10dlu, left:pref:grow(1), 4dlu,"
699:                                + "left:pref:grow(1), 4dlu, left:pref:grow(1), "
700:                                + "4dlu, left:pref:grow(1)", "");
701:                lm.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
702:                DefaultFormBuilder builder = new DefaultFormBuilder(lm,
703:                        new ScrollablePanel());
704:                builder.setDefaultDialogBorder();
705:
706:                builder.append("");
707:                JLabel bLabel = new JLabel("Buttons");
708:                bLabel.setIcon(Check.getIcon("JButtonColor16"));
709:                JLabel tbLabel = new JLabel("Toggle buttons");
710:                tbLabel.setIcon(Check.getIcon("JToggleButtonColor16"));
711:                JLabel cbLabel = new JLabel("Check boxes");
712:                cbLabel.setIcon(Check.getIcon("JCheckBoxColor16"));
713:                JLabel rbLabel = new JLabel("Radio buttons");
714:                rbLabel.setIcon(Check.getIcon("JRadioButtonColor16"));
715:
716:                // bLabel.setFont(bLabel.getFont().deriveFont(Font.BOLD));
717:                // tbLabel.setFont(rbLabel.getFont().deriveFont(Font.BOLD));
718:                // cbLabel.setFont(cbLabel.getFont().deriveFont(Font.BOLD));
719:                // rbLabel.setFont(rbLabel.getFont().deriveFont(Font.BOLD));
720:
721:                builder.append(bLabel, tbLabel);
722:                builder.append(cbLabel, rbLabel);
723:
724:                builder.appendSeparator("Regular settings");
725:
726:                this .addRow(builder, "Enabled", null, null);
727:                this .addRow(builder, "Disabled", null, new DisableCommand());
728:                this .addRow(builder, "Selected", null, new SelectCommand());
729:                this .addRow(builder, "Disabled selected", null,
730:                        new ChainCommand<Component>(new DisableCommand(),
731:                                new SelectCommand()));
732:                this 
733:                        .addRow(
734:                                builder,
735:                                "HTML text",
736:                                null,
737:                                new TextCommand(
738:                                        "<html>text <b>text</b> <font color='red'>text</font>"));
739:                this .addRow(builder, "With tooltip", null,
740:                        new TooltipTextCommand("Sample tooltip"));
741:                this 
742:                        .addRow(builder, "Popup menu", null,
743:                                new PopupMenuCommand());
744:                this .addRow(builder, "With icon", Check.getIcon("flag_sweden"),
745:                        new IconCommand(Check.getIcon("flag_sweden")));
746:
747:                builder.appendSeparator("Color settings");
748:                this .addRow(builder, "Barby Pink", null, new ThemeCommand(
749:                        new SubstanceBarbyPinkTheme()));
750:                this .addRow(builder, "Bottle Green", null, new ThemeCommand(
751:                        "Bottle Green"));
752:                this .addRow(builder, "Steel Blue", null, new ThemeCommand(
753:                        new SubstanceSteelBlueTheme()));
754:                this .addRow(builder, "Aqua & Sunset", null, new ThemeCommand(
755:                        new SubstanceMixTheme(new SubstanceAquaTheme(),
756:                                new SubstanceSunsetTheme())));
757:                this .addRow(builder, "Green & Pink", null, new ThemeCommand(
758:                        new SubstanceMixTheme(new SubstanceLimeGreenTheme(),
759:                                new SubstanceBarbyPinkTheme())));
760:                this .addRow(builder, "Always active", null,
761:                        new PaintActiveCommand());
762:                this .addRow(builder, "Always green", null,
763:                        new ChainCommand<AbstractButton>(new ThemeCommand(
764:                                new SubstanceBottleGreenTheme()),
765:                                new PaintActiveCommand()));
766:
767:                builder.appendSeparator("Focus indications");
768:                this .addRow(builder, "No focus painted", null,
769:                        new NoFocusCommand());
770:                this .addRow(builder, "None", null, new FocusKindCommand(
771:                        FocusKind.NONE));
772:                this .addRow(builder, "Text", null, new FocusKindCommand(
773:                        FocusKind.TEXT));
774:                this .addRow(builder, "All", null, new FocusKindCommand(
775:                        FocusKind.ALL));
776:                this .addRow(builder, "All inner", null, new FocusKindCommand(
777:                        FocusKind.ALL_INNER));
778:                this .addRow(builder, "All strong inner", null,
779:                        new FocusKindCommand(FocusKind.ALL_STRONG_INNER));
780:                this .addRow(builder, "Underline", null, new FocusKindCommand(
781:                        FocusKind.UNDERLINE));
782:                this .addRow(builder, "Strong underline", null,
783:                        new FocusKindCommand(FocusKind.STRONG_UNDERLINE));
784:
785:                builder.appendSeparator("Animation speed settings");
786:                this .addRow(builder, "None", null, new AnimationKindCommand(
787:                        AnimationKind.NONE));
788:                this .addRow(builder, "Fast", null, new AnimationKindCommand(
789:                        AnimationKind.FAST));
790:                this .addRow(builder, "Regular", null, new AnimationKindCommand(
791:                        AnimationKind.REGULAR));
792:                this .addRow(builder, "Slow", null, new AnimationKindCommand(
793:                        AnimationKind.SLOW));
794:                this .addRow(builder, "Debug", null, new AnimationKindCommand(
795:                        AnimationKind.DEBUG));
796:
797:                builder.appendSeparator("Size settings");
798:                this .addRow(builder, "No min size", null,
799:                        new NoMinSizeCommand());
800:                this 
801:                        .addRow(builder, "Custom margin", null,
802:                                new MarginCommand());
803:
804:                builder.appendSeparator("Side settings");
805:                this .addRow(builder, "Straight top", null,
806:                        new StraightSideCommand(Side.TOP.name()));
807:                this .addRow(builder, "Straight bottom", null,
808:                        new StraightSideCommand(Side.BOTTOM));
809:                this .addRow(builder, "Straight left", null,
810:                        new StraightSideCommand(
811:                                new String[] { Side.LEFT.name() }));
812:                this .addRow(builder, "Straight right", null,
813:                        new StraightSideCommand(new Side[] { Side.RIGHT }));
814:
815:                this .addRow(builder, "Open top", null,
816:                        new ChainCommand<AbstractButton>(
817:                                new StraightSideCommand(Side.TOP.name()),
818:                                new OpenSideCommand(Side.TOP.name())));
819:                this .addRow(builder, "Open bottom", null,
820:                        new ChainCommand<AbstractButton>(
821:                                new StraightSideCommand(Side.BOTTOM),
822:                                new OpenSideCommand(Side.BOTTOM)));
823:                this .addRow(builder, "Open left", null,
824:                        new ChainCommand<AbstractButton>(
825:                                new StraightSideCommand(
826:                                        new String[] { Side.LEFT.name() }),
827:                                new OpenSideCommand(new String[] { Side.LEFT
828:                                        .name() })));
829:                this 
830:                        .addRow(builder, "Open right", null,
831:                                new ChainCommand<AbstractButton>(
832:                                        new StraightSideCommand(
833:                                                new Side[] { Side.RIGHT }),
834:                                        new OpenSideCommand(
835:                                                new Side[] { Side.RIGHT })));
836:
837:                builder.appendSeparator("Unicode texts");
838:                this .addRow(builder, "Hebrew", null,
839:                        new ChainCommand<AbstractButton>(new TextCommand(
840:                                "\u05D0\u05D1\u05D2"), new IconCommand(Check
841:                                .getIcon("flag_israel"))));
842:                this .addRow(builder, "Chinese", null,
843:                        new ChainCommand<AbstractButton>(new FontCommand(
844:                                new Font("Arial Unicode MS", Font.PLAIN, 11)),
845:                                new TextCommand("\u4E01\u4E02\u4E03"),
846:                                new IconCommand(Check.getIcon("flag_china"))));
847:                this .addRow(builder, "Cyrillic", null,
848:                        new ChainCommand<AbstractButton>(new TextCommand(
849:                                "\u0430\u0431\u0432"), new IconCommand(Check
850:                                .getIcon("flag_russia"))));
851:                this .addRow(builder, "Greek", null,
852:                        new ChainCommand<AbstractButton>(new TextCommand(
853:                                "\u03B1\u03B2\u03B3"), new IconCommand(Check
854:                                .getIcon("flag_greece"))));
855:                this .addRow(builder, "Latin", null,
856:                        new ChainCommand<AbstractButton>(new TextCommand(
857:                                "\u00E6\u00F0\u0127\u2248"), new IconCommand(
858:                                Check.getIcon("flag_italy"))));
859:
860:                if (UIManager.getLookAndFeel() instanceof  SubstanceLookAndFeel) {
861:                    builder.appendSeparator("Shaper settings");
862:                    Map<String, ButtonShaperInfo> allButtonShapers = SubstanceLookAndFeel
863:                            .getAllButtonShapers();
864:                    for (ButtonShaperInfo bsi : allButtonShapers.values()) {
865:                        try {
866:                            this .addRow(builder, bsi.getDisplayName(), null,
867:                                    new ShaperCommand(Class.forName(
868:                                            bsi.getClassName()).newInstance()));
869:                        } catch (Exception exc) {
870:                        }
871:                    }
872:                }
873:
874:                if (UIManager.getLookAndFeel() instanceof  SubstanceLookAndFeel) {
875:                    builder.appendSeparator("Gradient painter settings");
876:                    Map<String, GradientPainterInfo> allGradientPainters = SubstanceLookAndFeel
877:                            .getAllGradientPainters();
878:                    for (GradientPainterInfo gpi : allGradientPainters.values()) {
879:                        try {
880:                            this .addRow(builder, gpi.getDisplayName(), null,
881:                                    new GradientPainterCommand(Class.forName(
882:                                            gpi.getClassName()).newInstance()));
883:                        } catch (Exception exc) {
884:                        }
885:                    }
886:                }
887:
888:                if (UIManager.getLookAndFeel() instanceof  SubstanceLookAndFeel) {
889:                    builder.appendSeparator("Border painter settings");
890:                    Map<String, BorderPainterInfo> allBorderPainters = SubstanceLookAndFeel
891:                            .getAllBorderPainters();
892:                    for (BorderPainterInfo bpi : allBorderPainters.values()) {
893:                        try {
894:                            this .addRow(builder, bpi.getDisplayName(), null,
895:                                    new BorderPainterCommand(Class.forName(
896:                                            bpi.getClassName()).newInstance()));
897:                        } catch (Exception exc) {
898:                        }
899:                    }
900:                }
901:
902:                builder.appendSeparator("Misc settings");
903:                this .addRow(builder, "No content area", null,
904:                        new NoContentAreaFilledCommand());
905:                this .addRow(builder, "No border", null,
906:                        new NoBorderPaintedCommand());
907:                this .addRow(builder, "No background", null,
908:                        new ChainCommand<AbstractButton>(
909:                                new NoContentAreaFilledCommand(),
910:                                new NoBorderPaintedCommand()));
911:                this .addRow(builder, "Flat", null, new ClientPropertyCommand(
912:                        SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE));
913:                this .addRow(builder, "Never", null, new ClientPropertyCommand(
914:                        SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY,
915:                        Boolean.TRUE));
916:
917:                this .addRow(builder, "Fixed font", null, new FontCommand(
918:                        new Font("Arial", Font.PLAIN, 12)));
919:                this .addRow(builder, "Null text", null, new TextCommand(null));
920:                this .addRow(builder, "Empty text", null, new TextCommand(""));
921:
922:                JPanel panel = builder.getPanel();
923:                JScrollPane jsp = new JScrollPane(panel);
924:                panel.setOpaque(false);
925:                jsp.setOpaque(false);
926:                jsp.getViewport().setOpaque(false);
927:                this.add(jsp, BorderLayout.CENTER);
928:            }
929:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.