Source Code Cross Referenced for ColorizedControlsPanel.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) 


0001:        /*
0002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
0003:         *
0004:         * Redistribution and use in source and binary forms, with or without 
0005:         * modification, are permitted provided that the following conditions are met:
0006:         * 
0007:         *  o Redistributions of source code must retain the above copyright notice, 
0008:         *    this list of conditions and the following disclaimer. 
0009:         *     
0010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
0011:         *    this list of conditions and the following disclaimer in the documentation 
0012:         *    and/or other materials provided with the distribution. 
0013:         *     
0014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of 
0015:         *    its contributors may be used to endorse or promote products derived 
0016:         *    from this software without specific prior written permission. 
0017:         *     
0018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
0019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
0020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
0021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
0022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
0024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
0025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
0026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
0027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
0028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
0029:         */
0030:        package test.check;
0031:
0032:        import java.awt.*;
0033:        import java.awt.event.ActionEvent;
0034:        import java.awt.event.ActionListener;
0035:        import java.text.DecimalFormat;
0036:        import java.util.Enumeration;
0037:
0038:        import javax.swing.*;
0039:        import javax.swing.event.ChangeEvent;
0040:        import javax.swing.event.ChangeListener;
0041:        import javax.swing.tree.*;
0042:
0043:        import org.jvnet.substance.SubstanceLookAndFeel;
0044:
0045:        import test.Check;
0046:        import test.check.command.*;
0047:
0048:        import com.jgoodies.forms.builder.DefaultFormBuilder;
0049:        import com.jgoodies.forms.layout.FormLayout;
0050:
0051:        /**
0052:         * Test application panel for testing colorized components.
0053:         * 
0054:         * @author Kirill Grouchnikov
0055:         */
0056:        public class ColorizedControlsPanel extends JPanel {
0057:            /**
0058:             * The default button.
0059:             */
0060:            public JButton defaultButton;
0061:
0062:            /**
0063:             * Returns a row of buttons, consisting of {@link JButton},
0064:             * {@link JToggleButton}, {@link JCheckBox} and {@link JRadioButton} in
0065:             * default states.
0066:             * 
0067:             * @return A row of buttons, consisting of {@link JButton},
0068:             *         {@link JToggleButton}, {@link JCheckBox} and
0069:             *         {@link JRadioButton} in default states.
0070:             */
0071:            private AbstractButton[] getRow() {
0072:                AbstractButton[] result = new AbstractButton[4];
0073:                result[0] = new JButton("sample");
0074:                result[1] = new JToggleButton("sample");
0075:                result[2] = new JCheckBox("sample");
0076:                result[3] = new JRadioButton("sample");
0077:                return result;
0078:            }
0079:
0080:            /**
0081:             * Adds a row of buttons configured with the specified text, icon and
0082:             * configuration command.
0083:             * 
0084:             * @param builder
0085:             *            Form builder.
0086:             * @param label
0087:             *            Text to set.
0088:             * @param icon
0089:             *            Icon to set.
0090:             * @param configurationCmd
0091:             *            Configuration command to apply.
0092:             */
0093:            private void addButtonRow(DefaultFormBuilder builder, String label,
0094:                    Icon icon, ConfigurationCommand<Component> configurationCmd) {
0095:                AbstractButton[] row = this .getRow();
0096:                if (configurationCmd != null) {
0097:                    for (AbstractButton ab : row) {
0098:                        configurationCmd.configure(ab);
0099:                        ab.setName(label + " " + ab.getClass().getSimpleName());
0100:                    }
0101:                }
0102:
0103:                JLabel jl = new JLabel(label);
0104:                if (icon != null)
0105:                    jl.setIcon(icon);
0106:                builder.append(jl);
0107:                for (AbstractButton ab : row)
0108:                    builder.append(ab);
0109:            }
0110:
0111:            /**
0112:             * Adds a row of components configured with the specified configuration
0113:             * command.
0114:             * 
0115:             * @param builder
0116:             *            Form builder.
0117:             * @param label
0118:             *            Text to set.
0119:             * @param creationCmd
0120:             *            Creation command.
0121:             * @param configurationCmd
0122:             *            Configuration command to apply.
0123:             */
0124:            private void addControlRow(DefaultFormBuilder builder,
0125:                    String label, CreationCommand<Component> creationCmd,
0126:                    ConfigurationCommand<Component> configurationCmd) {
0127:
0128:                Component[] row = new Component[4];
0129:                row[0] = creationCmd.create();
0130:                row[0].setBackground(Color.yellow);
0131:                row[1] = creationCmd.create();
0132:                row[1].setBackground(Color.blue);
0133:                row[1].setForeground(Color.red);
0134:                row[2] = creationCmd.create();
0135:                row[2].setBackground(Color.green);
0136:                row[3] = creationCmd.create();
0137:                row[3].setBackground(Color.green.darker());
0138:
0139:                if (configurationCmd != null) {
0140:                    for (Component comp : row) {
0141:                        configurationCmd.configure(comp);
0142:                    }
0143:                }
0144:
0145:                JLabel jl = new JLabel(label);
0146:                builder.append(jl);
0147:                for (Component comp : row)
0148:                    builder.append(comp);
0149:            }
0150:
0151:            private void addInternalFrame(JDesktopPane desktopPane,
0152:                    CreationCommand creationCommand,
0153:                    ConfigurationCommand<Component> configCommand) {
0154:                JInternalFrame jif = (JInternalFrame) creationCommand.create();
0155:                desktopPane.add(jif);
0156:                configCommand.configure(jif);
0157:            }
0158:
0159:            /**
0160:             * Creates a new button panel.
0161:             */
0162:            @SuppressWarnings("unchecked")
0163:            public ColorizedControlsPanel() {
0164:                this .setLayout(new BorderLayout());
0165:
0166:                FormLayout lmButtons = new FormLayout(
0167:                        "right:pref, 10dlu, left:pref:grow(1), 4dlu,"
0168:                                + "left:pref:grow(1), 4dlu, left:pref:grow(1), "
0169:                                + "4dlu, left:pref:grow(1)", "");
0170:                lmButtons.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
0171:                DefaultFormBuilder builderButtons = new DefaultFormBuilder(
0172:                        lmButtons, new ScrollablePanel());
0173:                builderButtons.setDefaultDialogBorder();
0174:
0175:                builderButtons.append("");
0176:                JLabel bLabel = new JLabel("Buttons");
0177:                bLabel.setIcon(Check.getIcon("JButtonColor16"));
0178:                JLabel tbLabel = new JLabel("Toggle buttons");
0179:                tbLabel.setIcon(Check.getIcon("JToggleButtonColor16"));
0180:                JLabel cbLabel = new JLabel("Check boxes");
0181:                cbLabel.setIcon(Check.getIcon("JCheckBoxColor16"));
0182:                JLabel rbLabel = new JLabel("Radio buttons");
0183:                rbLabel.setIcon(Check.getIcon("JRadioButtonColor16"));
0184:
0185:                builderButtons.append(bLabel, tbLabel);
0186:                builderButtons.append(cbLabel, rbLabel);
0187:
0188:                builderButtons.appendSeparator("Regular settings");
0189:
0190:                this .addButtonRow(builderButtons, "Enabled", null, null);
0191:                this .addButtonRow(builderButtons, "Flat", null,
0192:                        new ClientPropertyCommand(
0193:                                SubstanceLookAndFeel.FLAT_PROPERTY,
0194:                                Boolean.TRUE));
0195:                this .addButtonRow(builderButtons, "Disabled", null,
0196:                        new DisableCommand());
0197:                this .addButtonRow(builderButtons, "Selected", null,
0198:                        new SelectCommand());
0199:                this .addButtonRow(builderButtons, "Disabled selected", null,
0200:                        new ChainCommand<Component>(new DisableCommand(),
0201:                                new SelectCommand()));
0202:
0203:                builderButtons.appendSeparator("Background settings");
0204:                this .addButtonRow(builderButtons, "Yellow", null,
0205:                        new BackgroundColorCommand(Color.yellow));
0206:                this .addButtonRow(builderButtons, "Yellow flat", null,
0207:                        new ChainCommand<Component>(new BackgroundColorCommand(
0208:                                Color.yellow), new ClientPropertyCommand(
0209:                                SubstanceLookAndFeel.FLAT_PROPERTY,
0210:                                Boolean.TRUE)));
0211:                this .addButtonRow(builderButtons, "Yellow disabled", null,
0212:                        new ChainCommand<Component>(new BackgroundColorCommand(
0213:                                Color.yellow), new DisableCommand()));
0214:                this .addButtonRow(builderButtons, "Yellow selected", null,
0215:                        new ChainCommand<Component>(new BackgroundColorCommand(
0216:                                Color.yellow), new SelectCommand()));
0217:                this .addButtonRow(builderButtons, "Yellow disabled selected",
0218:                        null, new ChainCommand<Component>(
0219:                                new BackgroundColorCommand(Color.yellow),
0220:                                new SelectCommand(), new DisableCommand()));
0221:                this .addButtonRow(builderButtons, "Red", null,
0222:                        new BackgroundColorCommand(Color.red));
0223:                this .addButtonRow(builderButtons, "Red disabled", null,
0224:                        new ChainCommand<Component>(new BackgroundColorCommand(
0225:                                Color.red), new DisableCommand()));
0226:                this .addButtonRow(builderButtons, "Red selected", null,
0227:                        new ChainCommand<Component>(new BackgroundColorCommand(
0228:                                Color.red), new SelectCommand()));
0229:                this .addButtonRow(builderButtons, "Red disabled selected",
0230:                        null, new ChainCommand<Component>(
0231:                                new BackgroundColorCommand(Color.red),
0232:                                new SelectCommand(), new DisableCommand()));
0233:                this .addButtonRow(builderButtons, "Green", null,
0234:                        new BackgroundColorCommand(Color.green));
0235:                this .addButtonRow(builderButtons, "Green disabled", null,
0236:                        new ChainCommand<Component>(new BackgroundColorCommand(
0237:                                Color.green), new DisableCommand()));
0238:                this .addButtonRow(builderButtons, "Green selected", null,
0239:                        new ChainCommand<Component>(new BackgroundColorCommand(
0240:                                Color.green), new SelectCommand()));
0241:                this .addButtonRow(builderButtons, "Green disabled selected",
0242:                        null, new ChainCommand<Component>(
0243:                                new BackgroundColorCommand(Color.green),
0244:                                new SelectCommand(), new DisableCommand()));
0245:                this .addButtonRow(builderButtons, "Dark Green", null,
0246:                        new BackgroundColorCommand(Color.green.darker()));
0247:                this .addButtonRow(builderButtons, "Dark Green disabled", null,
0248:                        new ChainCommand<Component>(new BackgroundColorCommand(
0249:                                Color.green.darker()), new DisableCommand()));
0250:                this .addButtonRow(builderButtons, "Dark Green selected", null,
0251:                        new ChainCommand<Component>(new BackgroundColorCommand(
0252:                                Color.green.darker()), new SelectCommand()));
0253:                this .addButtonRow(builderButtons,
0254:                        "Dark Green disabled selected", null,
0255:                        new ChainCommand<Component>(new BackgroundColorCommand(
0256:                                Color.green.darker()), new SelectCommand(),
0257:                                new DisableCommand()));
0258:
0259:                builderButtons.appendSeparator("Foreground settings");
0260:                this .addButtonRow(builderButtons, "Yellow", null,
0261:                        new ForegroundColorCommand(Color.yellow));
0262:                this .addButtonRow(builderButtons, "Yellow disabled", null,
0263:                        new ChainCommand<Component>(new ForegroundColorCommand(
0264:                                Color.yellow), new DisableCommand()));
0265:                this .addButtonRow(builderButtons, "Yellow selected", null,
0266:                        new ChainCommand<Component>(new ForegroundColorCommand(
0267:                                Color.yellow), new SelectCommand()));
0268:                this .addButtonRow(builderButtons, "Yellow disabled selected",
0269:                        null, new ChainCommand<Component>(
0270:                                new ForegroundColorCommand(Color.yellow),
0271:                                new SelectCommand(), new DisableCommand()));
0272:                this .addButtonRow(builderButtons, "Red", null,
0273:                        new ForegroundColorCommand(Color.red));
0274:                this .addButtonRow(builderButtons, "Red disabled", null,
0275:                        new ChainCommand<Component>(new ForegroundColorCommand(
0276:                                Color.red), new DisableCommand()));
0277:                this .addButtonRow(builderButtons, "Red selected", null,
0278:                        new ChainCommand<Component>(new ForegroundColorCommand(
0279:                                Color.red), new SelectCommand()));
0280:                this .addButtonRow(builderButtons, "Red disabled selected",
0281:                        null, new ChainCommand<Component>(
0282:                                new ForegroundColorCommand(Color.red),
0283:                                new SelectCommand(), new DisableCommand()));
0284:                this .addButtonRow(builderButtons, "Green", null,
0285:                        new ForegroundColorCommand(Color.green));
0286:                this .addButtonRow(builderButtons, "Green disabled", null,
0287:                        new ChainCommand<Component>(new ForegroundColorCommand(
0288:                                Color.green), new DisableCommand()));
0289:                this .addButtonRow(builderButtons, "Green selected", null,
0290:                        new ChainCommand<Component>(new ForegroundColorCommand(
0291:                                Color.green), new SelectCommand()));
0292:                this .addButtonRow(builderButtons, "Green disabled selected",
0293:                        null, new ChainCommand<Component>(
0294:                                new ForegroundColorCommand(Color.green),
0295:                                new SelectCommand(), new DisableCommand()));
0296:                this .addButtonRow(builderButtons, "Dark Green", null,
0297:                        new ForegroundColorCommand(Color.green.darker()));
0298:                this .addButtonRow(builderButtons, "Dark Green disabled", null,
0299:                        new ChainCommand<Component>(new ForegroundColorCommand(
0300:                                Color.green.darker()), new DisableCommand()));
0301:                this .addButtonRow(builderButtons, "Dark Green selected", null,
0302:                        new ChainCommand<Component>(new ForegroundColorCommand(
0303:                                Color.green.darker()), new SelectCommand()));
0304:                this .addButtonRow(builderButtons,
0305:                        "Dark Green disabled selected", null,
0306:                        new ChainCommand<Component>(new ForegroundColorCommand(
0307:                                Color.green.darker()), new SelectCommand(),
0308:                                new DisableCommand()));
0309:
0310:                builderButtons.appendSeparator("Combined settings");
0311:                this .addButtonRow(builderButtons, "Blue/yellow", null,
0312:                        new ChainCommand<Component>(new ForegroundColorCommand(
0313:                                Color.blue), new BackgroundColorCommand(
0314:                                Color.yellow)));
0315:                this .addButtonRow(builderButtons, "Blue/yellow disabled", null,
0316:                        new ChainCommand<Component>(new ForegroundColorCommand(
0317:                                Color.blue), new BackgroundColorCommand(
0318:                                Color.yellow), new DisableCommand()));
0319:                this .addButtonRow(builderButtons, "Blue/yellow selected", null,
0320:                        new ChainCommand<Component>(new ForegroundColorCommand(
0321:                                Color.blue), new BackgroundColorCommand(
0322:                                Color.yellow), new SelectCommand()));
0323:                this .addButtonRow(builderButtons,
0324:                        "Blue/yellow disabled selected", null,
0325:                        new ChainCommand<Component>(new ForegroundColorCommand(
0326:                                Color.blue), new BackgroundColorCommand(
0327:                                Color.yellow), new SelectCommand(),
0328:                                new DisableCommand()));
0329:                this .addButtonRow(builderButtons, "Red/light green", null,
0330:                        new ChainCommand<Component>(new ForegroundColorCommand(
0331:                                Color.red), new BackgroundColorCommand(
0332:                                Color.green.brighter())));
0333:                this .addButtonRow(builderButtons, "Red/light green disabled",
0334:                        null, new ChainCommand<Component>(
0335:                                new ForegroundColorCommand(Color.red),
0336:                                new BackgroundColorCommand(Color.green
0337:                                        .brighter()), new DisableCommand()));
0338:                this .addButtonRow(builderButtons, "Red/light green selected",
0339:                        null, new ChainCommand<Component>(
0340:                                new ForegroundColorCommand(Color.red),
0341:                                new BackgroundColorCommand(Color.green
0342:                                        .brighter()), new SelectCommand()));
0343:                this .addButtonRow(builderButtons,
0344:                        "Red/light green disabled selected", null,
0345:                        new ChainCommand<Component>(new ForegroundColorCommand(
0346:                                Color.red), new BackgroundColorCommand(
0347:                                Color.green.brighter()), new SelectCommand(),
0348:                                new DisableCommand()));
0349:                this .addButtonRow(builderButtons, "Dark yellow/blue", null,
0350:                        new ChainCommand<Component>(new ForegroundColorCommand(
0351:                                Color.yellow.darker()),
0352:                                new BackgroundColorCommand(Color.blue)));
0353:                this .addButtonRow(builderButtons, "Dark yellow/blue disabled",
0354:                        null, new ChainCommand<Component>(
0355:                                new ForegroundColorCommand(Color.yellow
0356:                                        .darker()), new BackgroundColorCommand(
0357:                                        Color.blue), new DisableCommand()));
0358:                this .addButtonRow(builderButtons, "Dark yellow/blue selected",
0359:                        null, new ChainCommand<Component>(
0360:                                new ForegroundColorCommand(Color.yellow
0361:                                        .darker()), new BackgroundColorCommand(
0362:                                        Color.blue), new SelectCommand()));
0363:                this .addButtonRow(builderButtons,
0364:                        "Dark yellow/blue disabled selected", null,
0365:                        new ChainCommand<Component>(new ForegroundColorCommand(
0366:                                Color.yellow.darker()),
0367:                                new BackgroundColorCommand(Color.blue),
0368:                                new SelectCommand(), new DisableCommand()));
0369:                this .addButtonRow(builderButtons, "Dark green/magenta", null,
0370:                        new ChainCommand<Component>(new ForegroundColorCommand(
0371:                                Color.green.darker()),
0372:                                new BackgroundColorCommand(Color.magenta)));
0373:                this .addButtonRow(builderButtons,
0374:                        "Dark green/magenta disabled", null,
0375:                        new ChainCommand<Component>(new ForegroundColorCommand(
0376:                                Color.green.darker()),
0377:                                new BackgroundColorCommand(Color.magenta),
0378:                                new DisableCommand()));
0379:                this .addButtonRow(builderButtons,
0380:                        "Dark green/magenta selected", null,
0381:                        new ChainCommand<Component>(new ForegroundColorCommand(
0382:                                Color.green.darker()),
0383:                                new BackgroundColorCommand(Color.magenta),
0384:                                new SelectCommand()));
0385:                this .addButtonRow(builderButtons,
0386:                        "Dark green/magenta disabled selected", null,
0387:                        new ChainCommand<Component>(new ForegroundColorCommand(
0388:                                Color.green.darker()),
0389:                                new BackgroundColorCommand(Color.magenta),
0390:                                new SelectCommand(), new DisableCommand()));
0391:
0392:                JPanel panelButtons = builderButtons.getPanel();
0393:                JScrollPane jspButtons = new JScrollPane(panelButtons);
0394:                panelButtons.setOpaque(false);
0395:                jspButtons.setOpaque(false);
0396:                jspButtons.getViewport().setOpaque(false);
0397:
0398:                FormLayout lmOther = new FormLayout(
0399:                        "right:pref, 10dlu, left:pref:grow(1), 4dlu,"
0400:                                + "left:pref:grow(1), 4dlu, left:pref:grow(1), "
0401:                                + "4dlu, left:pref:grow(1)", "");
0402:                lmOther.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
0403:                DefaultFormBuilder builderOther = new DefaultFormBuilder(
0404:                        lmOther, new ScrollablePanel());
0405:                builderOther.setDefaultDialogBorder();
0406:
0407:                builderOther.append("");
0408:                builderOther.append(new JLabel("Yellow"), new JLabel("Blue"));
0409:                builderOther.append(new JLabel("Green"), new JLabel(
0410:                        "Dark green"));
0411:
0412:                builderOther.appendSeparator("Labels");
0413:                addControlRow(builderOther, "Regular",
0414:                        new CreationCommand<Component>() {
0415:                            public Component create() {
0416:                                return new JLabel("label");
0417:                            }
0418:                        }, null);
0419:                addControlRow(builderOther, "Disabled",
0420:                        new CreationCommand<Component>() {
0421:                            public Component create() {
0422:                                return new JLabel("label");
0423:                            }
0424:                        }, new DisableCommand());
0425:                addControlRow(builderOther, "Regular + foreground",
0426:                        new CreationCommand<Component>() {
0427:                            public Component create() {
0428:                                return new JLabel("label");
0429:                            }
0430:                        }, new ForegroundColorCommand(Color.red));
0431:                addControlRow(builderOther, "Disabled + foreground",
0432:                        new CreationCommand<Component>() {
0433:                            public Component create() {
0434:                                return new JLabel("label");
0435:                            }
0436:                        }, new ChainCommand<Component>(
0437:                                new ForegroundColorCommand(Color.red),
0438:                                new DisableCommand()));
0439:                addControlRow(builderOther, "HTML",
0440:                        new CreationCommand<Component>() {
0441:                            public Component create() {
0442:                                return new JLabel(
0443:                                        "<html>text <b>text</b> <font color='red'>text</font>");
0444:                            }
0445:                        }, null);
0446:
0447:                builderOther.appendSeparator("Sliders");
0448:                addControlRow(builderOther, "Regular",
0449:                        new CreationCommand<Component>() {
0450:                            public Component create() {
0451:                                return new JSlider(0, 100, 50);
0452:                            }
0453:                        }, null);
0454:                addControlRow(builderOther, "Disabled",
0455:                        new CreationCommand<Component>() {
0456:                            public Component create() {
0457:                                return new JSlider(0, 100, 50);
0458:                            }
0459:                        }, new DisableCommand());
0460:
0461:                builderOther.appendSeparator("Progress bars");
0462:                addControlRow(builderOther, "Regular",
0463:                        new CreationCommand<Component>() {
0464:                            public Component create() {
0465:                                JProgressBar jpb = new JProgressBar(0, 100);
0466:                                jpb.setIndeterminate(false);
0467:                                jpb.setValue(50);
0468:                                jpb.setStringPainted(true);
0469:                                return jpb;
0470:                            }
0471:                        }, null);
0472:                addControlRow(builderOther, "Disabled",
0473:                        new CreationCommand<Component>() {
0474:                            public Component create() {
0475:                                JProgressBar jpb = new JProgressBar(0, 100);
0476:                                jpb.setIndeterminate(false);
0477:                                jpb.setValue(50);
0478:                                jpb.setStringPainted(true);
0479:                                return jpb;
0480:                            }
0481:                        }, new DisableCommand());
0482:                addControlRow(builderOther, "Custom foreground",
0483:                        new CreationCommand<Component>() {
0484:                            public Component create() {
0485:                                JProgressBar jpb = new JProgressBar(0, 100);
0486:                                jpb.setIndeterminate(false);
0487:                                jpb.setValue(50);
0488:                                jpb.setStringPainted(true);
0489:                                return jpb;
0490:                            }
0491:                        }, new ForegroundColorCommand(Color.red));
0492:                addControlRow(builderOther, "Disabled with foreground",
0493:                        new CreationCommand<Component>() {
0494:                            public Component create() {
0495:                                JProgressBar jpb = new JProgressBar(0, 100);
0496:                                jpb.setIndeterminate(false);
0497:                                jpb.setValue(50);
0498:                                jpb.setStringPainted(true);
0499:                                return jpb;
0500:                            }
0501:                        }, new ChainCommand<Component>(new DisableCommand(),
0502:                                new ForegroundColorCommand(Color.red)));
0503:                addControlRow(builderOther, "Indeterminate",
0504:                        new CreationCommand<Component>() {
0505:                            public Component create() {
0506:                                JProgressBar jpb = new JProgressBar(0, 100);
0507:                                jpb.setIndeterminate(true);
0508:                                return jpb;
0509:                            }
0510:                        }, null);
0511:                addControlRow(builderOther, "Indeterminate disabled",
0512:                        new CreationCommand<Component>() {
0513:                            public Component create() {
0514:                                JProgressBar jpb = new JProgressBar(0, 100);
0515:                                jpb.setIndeterminate(true);
0516:                                return jpb;
0517:                            }
0518:                        }, new DisableCommand());
0519:
0520:                builderOther.appendSeparator("Combo boxes");
0521:                addControlRow(builderOther, "Regular",
0522:                        new CreationCommand<Component>() {
0523:                            public Component create() {
0524:                                JComboBox jcb = new JComboBox(new Object[] {
0525:                                        "Ester", "Jordi", "Jordina", "Jorge",
0526:                                        "Sergi" });
0527:                                return jcb;
0528:                            }
0529:                        }, null);
0530:                addControlRow(builderOther, "Flat",
0531:                        new CreationCommand<Component>() {
0532:                            public Component create() {
0533:                                JComboBox jcb = new JComboBox(new Object[] {
0534:                                        "Ester", "Jordi", "Jordina", "Jorge",
0535:                                        "Sergi" });
0536:                                return jcb;
0537:                            }
0538:                        }, new ClientPropertyCommand(
0539:                                SubstanceLookAndFeel.FLAT_PROPERTY,
0540:                                Boolean.TRUE));
0541:                addControlRow(builderOther, "Disabled",
0542:                        new CreationCommand<Component>() {
0543:                            public Component create() {
0544:                                JComboBox jcb = new JComboBox(new Object[] {
0545:                                        "Ester", "Jordi", "Jordina", "Jorge",
0546:                                        "Sergi" });
0547:                                return jcb;
0548:                            }
0549:                        }, new DisableCommand());
0550:                addControlRow(builderOther, "Editable",
0551:                        new CreationCommand<Component>() {
0552:                            public Component create() {
0553:                                JComboBox jcb = new JComboBox(new Object[] {
0554:                                        "Ester", "Jordi", "Jordina", "Jorge",
0555:                                        "Sergi" });
0556:                                jcb.setEditable(true);
0557:                                return jcb;
0558:                            }
0559:                        }, null);
0560:                addControlRow(builderOther, "Disabled editable",
0561:                        new CreationCommand<Component>() {
0562:                            public Component create() {
0563:                                JComboBox jcb = new JComboBox(new Object[] {
0564:                                        "Ester", "Jordi", "Jordina", "Jorge",
0565:                                        "Sergi" });
0566:                                jcb.setEditable(true);
0567:                                return jcb;
0568:                            }
0569:                        }, new DisableCommand());
0570:
0571:                CreationCommand<Component> spinnerCreationCmd = new CreationCommand<Component>() {
0572:                    public Component create() {
0573:                        JSpinner s = new JSpinner(
0574:                                new SpinnerListModel(new Object[] { "sample0",
0575:                                        "sample", "sample2" }));
0576:                        s.getModel().setValue("sample");
0577:                        return s;
0578:                    }
0579:                };
0580:                builderOther.appendSeparator("Spinners");
0581:                addControlRow(builderOther, "Regular", spinnerCreationCmd, null);
0582:                addControlRow(builderOther, "Flat", spinnerCreationCmd,
0583:                        new ClientPropertyCommand(
0584:                                SubstanceLookAndFeel.FLAT_PROPERTY,
0585:                                Boolean.TRUE));
0586:                addControlRow(builderOther, "Disabled", spinnerCreationCmd,
0587:                        new DisableCommand());
0588:
0589:                JPanel panelOther = builderOther.getPanel();
0590:                JScrollPane jspOther = new JScrollPane(panelOther);
0591:                panelOther.setOpaque(false);
0592:                jspOther.setOpaque(false);
0593:                jspOther.getViewport().setOpaque(false);
0594:
0595:                FormLayout lmText = new FormLayout(
0596:                        "right:pref, 10dlu, left:pref:grow(1), 4dlu,"
0597:                                + "left:pref:grow(1), 4dlu, left:pref:grow(1), "
0598:                                + "4dlu, left:pref:grow(1)", "");
0599:                lmText.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
0600:                DefaultFormBuilder builderText = new DefaultFormBuilder(lmText,
0601:                        new ScrollablePanel());
0602:                builderText.setDefaultDialogBorder();
0603:
0604:                builderText.append("");
0605:                builderText.append(new JLabel("Yellow"), new JLabel(
0606:                        "Blue + red"));
0607:                builderText.append(new JLabel("Green"),
0608:                        new JLabel("Dark green"));
0609:
0610:                builderText.appendSeparator("Text fields");
0611:                addControlRow(builderText, "Regular",
0612:                        new CreationCommand<Component>() {
0613:                            public Component create() {
0614:                                JTextField field = new JTextField("test", 15);
0615:                                return field;
0616:                            }
0617:                        }, null);
0618:                addControlRow(builderText, "Watermark",
0619:                        new CreationCommand<Component>() {
0620:                            public Component create() {
0621:                                JTextField field = new JTextField("test", 15);
0622:                                return field;
0623:                            }
0624:                        }, new ClientPropertyCommand(
0625:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0626:                                Boolean.TRUE));
0627:                addControlRow(builderText, "Disabled",
0628:                        new CreationCommand<Component>() {
0629:                            public Component create() {
0630:                                JTextField field = new JTextField("test", 15);
0631:                                return field;
0632:                            }
0633:                        }, new DisableCommand());
0634:                addControlRow(builderText, "Not editable",
0635:                        new CreationCommand<Component>() {
0636:                            public Component create() {
0637:                                JTextField field = new JTextField("test", 15);
0638:                                field.setEditable(false);
0639:                                return field;
0640:                            }
0641:                        }, null);
0642:
0643:                builderText.appendSeparator("Formatted text fields");
0644:                addControlRow(builderText, "Regular",
0645:                        new CreationCommand<Component>() {
0646:                            public Component create() {
0647:                                JFormattedTextField field = new JFormattedTextField(
0648:                                        new DecimalFormat("#,##0.0000"));
0649:                                field.setText("2,430.0000");
0650:                                return field;
0651:                            }
0652:                        }, null);
0653:                addControlRow(builderText, "Watermark",
0654:                        new CreationCommand<Component>() {
0655:                            public Component create() {
0656:                                JFormattedTextField field = new JFormattedTextField(
0657:                                        new DecimalFormat("#,##0.0000"));
0658:                                field.setText("2,430.0000");
0659:                                return field;
0660:                            }
0661:                        }, new ClientPropertyCommand(
0662:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0663:                                Boolean.TRUE));
0664:                addControlRow(builderText, "Disabled",
0665:                        new CreationCommand<Component>() {
0666:                            public Component create() {
0667:                                JFormattedTextField field = new JFormattedTextField(
0668:                                        new DecimalFormat("#,##0.0000"));
0669:                                field.setText("2,430.0000");
0670:                                return field;
0671:                            }
0672:                        }, new DisableCommand());
0673:                addControlRow(builderText, "Not editable",
0674:                        new CreationCommand<Component>() {
0675:                            public Component create() {
0676:                                JFormattedTextField field = new JFormattedTextField(
0677:                                        new DecimalFormat("#,##0.0000"));
0678:                                field.setText("2,430.0000");
0679:                                field.setEditable(false);
0680:                                return field;
0681:                            }
0682:                        }, null);
0683:
0684:                builderText.appendSeparator("Password fields");
0685:                addControlRow(builderText, "Regular",
0686:                        new CreationCommand<Component>() {
0687:                            public Component create() {
0688:                                JPasswordField field = new JPasswordField(
0689:                                        "password", 15);
0690:                                return field;
0691:                            }
0692:                        }, null);
0693:                addControlRow(builderText, "Watermark",
0694:                        new CreationCommand<Component>() {
0695:                            public Component create() {
0696:                                JPasswordField field = new JPasswordField(
0697:                                        "password", 15);
0698:                                return field;
0699:                            }
0700:                        }, new ClientPropertyCommand(
0701:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0702:                                Boolean.TRUE));
0703:                addControlRow(builderText, "Disabled",
0704:                        new CreationCommand<Component>() {
0705:                            public Component create() {
0706:                                JPasswordField field = new JPasswordField(
0707:                                        "password", 15);
0708:                                return field;
0709:                            }
0710:                        }, new DisableCommand());
0711:                addControlRow(builderText, "Not editable",
0712:                        new CreationCommand<Component>() {
0713:                            public Component create() {
0714:                                JPasswordField field = new JPasswordField(
0715:                                        "password", 15);
0716:                                field.setEditable(false);
0717:                                return field;
0718:                            }
0719:                        }, null);
0720:
0721:                builderText.appendSeparator("Editor panes");
0722:                addControlRow(builderText, "Regular",
0723:                        new CreationCommand<Component>() {
0724:                            public Component create() {
0725:                                JEditorPane pane = new JEditorPane(
0726:                                        "text/html;",
0727:                                        "Sample <b>content</b><br> <u>text</u>");
0728:                                return pane;
0729:                            }
0730:                        }, null);
0731:                addControlRow(builderText, "Watermark",
0732:                        new CreationCommand<Component>() {
0733:                            public Component create() {
0734:                                JEditorPane pane = new JEditorPane(
0735:                                        "text/html;",
0736:                                        "Sample <b>content</b><br> <u>text</u>");
0737:                                return pane;
0738:                            }
0739:                        }, new ClientPropertyCommand(
0740:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0741:                                Boolean.TRUE));
0742:                addControlRow(builderText, "Disabled",
0743:                        new CreationCommand<Component>() {
0744:                            public Component create() {
0745:                                JEditorPane pane = new JEditorPane(
0746:                                        "text/html;",
0747:                                        "Sample <b>content</b><br> <u>text</u>");
0748:                                return pane;
0749:                            }
0750:                        }, new DisableCommand());
0751:                addControlRow(builderText, "Not editable",
0752:                        new CreationCommand<Component>() {
0753:                            public Component create() {
0754:                                JEditorPane pane = new JEditorPane(
0755:                                        "text/html;",
0756:                                        "Sample <b>content</b><br> <u>text</u>");
0757:                                pane.setEditable(false);
0758:                                return pane;
0759:                            }
0760:                        }, null);
0761:
0762:                builderText.appendSeparator("Text areas");
0763:                addControlRow(builderText, "Regular",
0764:                        new CreationCommand<Component>() {
0765:                            public Component create() {
0766:                                JTextArea area = new JTextArea(
0767:                                        "Sample content text", 3, 15);
0768:                                return area;
0769:                            }
0770:                        }, null);
0771:                addControlRow(builderText, "Watermark",
0772:                        new CreationCommand<Component>() {
0773:                            public Component create() {
0774:                                JTextArea area = new JTextArea(
0775:                                        "Sample content text", 3, 15);
0776:                                return area;
0777:                            }
0778:                        }, new ClientPropertyCommand(
0779:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0780:                                Boolean.TRUE));
0781:                addControlRow(builderText, "Disabled",
0782:                        new CreationCommand<Component>() {
0783:                            public Component create() {
0784:                                JTextArea area = new JTextArea(
0785:                                        "Sample content text", 3, 15);
0786:                                return area;
0787:                            }
0788:                        }, new DisableCommand());
0789:                addControlRow(builderText, "Not editable",
0790:                        new CreationCommand<Component>() {
0791:                            public Component create() {
0792:                                JTextArea area = new JTextArea(
0793:                                        "Sample content text", 3, 15);
0794:                                area.setEditable(false);
0795:                                return area;
0796:                            }
0797:                        }, null);
0798:
0799:                builderText.appendSeparator("Text panes");
0800:                addControlRow(builderText, "Regular",
0801:                        new CreationCommand<Component>() {
0802:                            public Component create() {
0803:                                JTextPane pane = new JTextPane();
0804:                                pane.replaceSelection("Sample content text");
0805:                                pane.setPreferredSize(new Dimension(120, 40));
0806:                                return pane;
0807:                            }
0808:                        }, null);
0809:                addControlRow(builderText, "Watermark",
0810:                        new CreationCommand<Component>() {
0811:                            public Component create() {
0812:                                JTextPane pane = new JTextPane();
0813:                                pane.replaceSelection("Sample content text");
0814:                                pane.setPreferredSize(new Dimension(120, 40));
0815:                                return pane;
0816:                            }
0817:                        }, new ClientPropertyCommand(
0818:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0819:                                Boolean.TRUE));
0820:                addControlRow(builderText, "Disabled",
0821:                        new CreationCommand<Component>() {
0822:                            public Component create() {
0823:                                JTextPane pane = new JTextPane();
0824:                                pane.replaceSelection("Sample content text");
0825:                                pane.setPreferredSize(new Dimension(120, 40));
0826:                                return pane;
0827:                            }
0828:                        }, new DisableCommand());
0829:                addControlRow(builderText, "Not editable",
0830:                        new CreationCommand<Component>() {
0831:                            public Component create() {
0832:                                JTextPane pane = new JTextPane();
0833:                                pane.replaceSelection("Sample content text");
0834:                                pane.setPreferredSize(new Dimension(120, 40));
0835:                                pane.setEditable(false);
0836:                                return pane;
0837:                            }
0838:                        }, null);
0839:
0840:                JPanel panelText = builderText.getPanel();
0841:                JScrollPane jspText = new JScrollPane(panelText);
0842:                panelText.setOpaque(false);
0843:                jspText.setOpaque(false);
0844:                jspText.getViewport().setOpaque(false);
0845:
0846:                JScrollPane coloredScrollPane = new JScrollPane(
0847:                        new CheckeredPanel());
0848:                coloredScrollPane.setBackground(Color.yellow);
0849:                coloredScrollPane.getVerticalScrollBar().setBackground(
0850:                        Color.green);
0851:
0852:                FormLayout lmCells = new FormLayout(
0853:                        "right:pref, 10dlu, fill:pref:grow(1), 4dlu,"
0854:                                + "fill:pref:grow(1), 4dlu, fill:pref:grow(1), "
0855:                                + "4dlu, fill:pref:grow(1)", "");
0856:                lmCells.setColumnGroups(new int[][] { { 3, 5, 7, 9 } });
0857:                DefaultFormBuilder builderCells = new DefaultFormBuilder(
0858:                        lmCells, new ScrollablePanel());
0859:                builderCells.setDefaultDialogBorder();
0860:
0861:                builderCells.append("");
0862:                builderCells.append(new JLabel("Yellow"), new JLabel("Blue"));
0863:                builderCells.append(new JLabel("Green"), new JLabel(
0864:                        "Dark green"));
0865:
0866:                builderCells.appendSeparator("Lists");
0867:                addControlRow(builderCells, "List",
0868:                        new CreationCommand<Component>() {
0869:                            public Component create() {
0870:                                JList list = new JList(new Object[] { "entry1",
0871:                                        "entry2", "entry3" });
0872:                                return list;
0873:                            }
0874:                        }, null);
0875:                addControlRow(builderCells, "List watermark",
0876:                        new CreationCommand<Component>() {
0877:                            public Component create() {
0878:                                JList list = new JList(new Object[] { "entry1",
0879:                                        "entry2", "entry3" });
0880:                                return list;
0881:                            }
0882:                        }, new ClientPropertyCommand(
0883:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0884:                                Boolean.TRUE));
0885:                addControlRow(builderCells, "List disabled",
0886:                        new CreationCommand<Component>() {
0887:                            public Component create() {
0888:                                JList list = new JList(new Object[] { "entry1",
0889:                                        "entry2", "entry3" });
0890:                                return list;
0891:                            }
0892:                        }, new DisableCommand());
0893:
0894:                CreationCommand<Component> tableCreationCmd = new CreationCommand<Component>() {
0895:                    public Component create() {
0896:                        final JTable table = new JTable(
0897:                                new Object[][] {
0898:                                        { "entry11", "entry12", "entry13" },
0899:                                        { "entry21", "entry22", "entry23" },
0900:                                        { "entry31", "entry32", "entry33" } },
0901:                                new Object[] { "Column1", "Column2", "Column3" });
0902:                        JScrollPane tableScroll = new JScrollPane(table) {
0903:                            @Override
0904:                            public void setBackground(Color bg) {
0905:                                super .setBackground(bg);
0906:                                table.setBackground(bg);
0907:                            }
0908:                        };
0909:                        Dimension prefTable = table.getPreferredSize();
0910:                        tableScroll.setPreferredSize(new Dimension(
0911:                                prefTable.width, prefTable.height + 25));
0912:                        return tableScroll;
0913:                    }
0914:                };
0915:                builderCells.appendSeparator("Tables");
0916:                addControlRow(builderCells, "Table", tableCreationCmd, null);
0917:                addControlRow(builderCells, "Table watermark",
0918:                        tableCreationCmd, new ClientPropertyCommand(
0919:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
0920:                                Boolean.TRUE));
0921:                addControlRow(builderCells, "Table disabled", tableCreationCmd,
0922:                        new DisableViewportCommand());
0923:
0924:                CreationCommand<Component> treeCreationCmd = new CreationCommand<Component>() {
0925:                    public void expandAll(JTree tree, boolean expand) {
0926:                        TreeNode root = (TreeNode) tree.getModel().getRoot();
0927:
0928:                        // Traverse tree from root
0929:                        expandAll(tree, new TreePath(root), expand);
0930:                    }
0931:
0932:                    private void expandAll(JTree tree, TreePath parent,
0933:                            boolean expand) {
0934:                        // Traverse children
0935:                        TreeNode node = (TreeNode) parent
0936:                                .getLastPathComponent();
0937:                        if (node.getChildCount() >= 0) {
0938:                            for (Enumeration e = node.children(); e
0939:                                    .hasMoreElements();) {
0940:                                TreeNode n = (TreeNode) e.nextElement();
0941:                                TreePath path = parent.pathByAddingChild(n);
0942:                                expandAll(tree, path, expand);
0943:                            }
0944:                        }
0945:
0946:                        // Expansion or collapse must be done bottom-up
0947:                        if (expand) {
0948:                            tree.expandPath(parent);
0949:                        } else {
0950:                            tree.collapsePath(parent);
0951:                        }
0952:                    }
0953:
0954:                    public Component create() {
0955:                        DefaultMutableTreeNode root = new DefaultMutableTreeNode(
0956:                                "root");
0957:                        DefaultMutableTreeNode son1 = new DefaultMutableTreeNode(
0958:                                "son1");
0959:                        DefaultMutableTreeNode son2 = new DefaultMutableTreeNode(
0960:                                "son2");
0961:                        DefaultMutableTreeNode son3 = new DefaultMutableTreeNode(
0962:                                "son3");
0963:                        DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode(
0964:                                "gson11");
0965:                        DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode(
0966:                                "gson12");
0967:                        DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode(
0968:                                "gson21");
0969:                        DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode(
0970:                                "gson22");
0971:                        DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode(
0972:                                "gson31");
0973:                        DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode(
0974:                                "gson32");
0975:                        DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode(
0976:                                "ggson111");
0977:                        DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode(
0978:                                "ggson112");
0979:                        DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode(
0980:                                "ggson113");
0981:
0982:                        gson11.add(ggson111);
0983:                        gson11.add(ggson112);
0984:                        gson11.add(ggson113);
0985:                        son1.add(gson11);
0986:                        son1.add(gson12);
0987:                        son2.add(gson21);
0988:                        son2.add(gson22);
0989:                        son3.add(gson31);
0990:                        son3.add(gson32);
0991:                        root.add(son1);
0992:                        root.add(son2);
0993:                        root.add(son3);
0994:
0995:                        JTree tree = new JTree(root);
0996:                        expandAll(tree, true);
0997:                        return tree;
0998:                    }
0999:                };
1000:                builderCells.appendSeparator("Trees");
1001:                addControlRow(builderCells, "Tree", treeCreationCmd, null);
1002:                addControlRow(builderCells, "Tree watermark", treeCreationCmd,
1003:                        new ClientPropertyCommand(
1004:                                SubstanceLookAndFeel.WATERMARK_TO_BLEED,
1005:                                Boolean.TRUE));
1006:                addControlRow(builderCells, "Tree disabled", treeCreationCmd,
1007:                        new DisableCommand());
1008:
1009:                JPanel panelCells = builderCells.getPanel();
1010:                JScrollPane jspCells = new JScrollPane(panelCells);
1011:                panelCells.setOpaque(false);
1012:                jspCells.setOpaque(false);
1013:                jspCells.getViewport().setOpaque(false);
1014:
1015:                JDesktopPane desktopPane = new JDesktopPane();
1016:                CreationCommand<Component> internalFrameCreationCmd = new CreationCommand<Component>() {
1017:                    public Component create() {
1018:                        JInternalFrame jif = new JInternalFrame(
1019:                                "Internal frame");
1020:                        jif.setLayout(new FlowLayout());
1021:                        JButton button = new JButton("red button");
1022:                        button.setBackground(Color.red);
1023:                        jif.add(button);
1024:                        jif.setClosable(true);
1025:                        jif.setMaximizable(true);
1026:                        jif.setIconifiable(true);
1027:                        jif.setResizable(true);
1028:                        jif.setVisible(true);
1029:
1030:                        JMenuBar jmb = new JMenuBar();
1031:                        JMenu coloredMenu = new JMenu("Colors");
1032:                        coloredMenu.setMnemonic('0');
1033:                        JMenuItem coloredMI = new JMenuItem("Italic red");
1034:                        coloredMI.setFont(coloredMI.getFont().deriveFont(
1035:                                Font.ITALIC));
1036:                        coloredMI.setForeground(Color.red);
1037:                        coloredMI.setBackground(Color.yellow);
1038:                        coloredMenu.add(coloredMI);
1039:                        JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem(
1040:                                "Bold green");
1041:                        coloredRBMI.setFont(coloredRBMI.getFont().deriveFont(
1042:                                Font.BOLD));
1043:                        coloredRBMI.setForeground(Color.green);
1044:                        coloredRBMI.setBackground(Color.blue.brighter());
1045:                        coloredMenu.add(coloredRBMI);
1046:                        JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem(
1047:                                "Big blue");
1048:                        coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(
1049:                                32f));
1050:                        coloredCBMI.setForeground(Color.blue);
1051:                        coloredCBMI.setBackground(Color.green.brighter());
1052:                        coloredMenu.add(coloredCBMI);
1053:                        JMenu coloredM = new JMenu("Always big magenta");
1054:                        coloredM.setForeground(Color.magenta);
1055:                        coloredM.setBackground(Color.red.darker());
1056:                        coloredM.setFont(coloredM.getFont().deriveFont(24f));
1057:                        coloredMenu.add(coloredM);
1058:                        jmb.add(coloredMenu);
1059:
1060:                        JMenu blueMenu = new JMenu("Blue");
1061:                        blueMenu.setForeground(Color.blue);
1062:                        blueMenu.setBackground(Color.yellow);
1063:                        jmb.add(blueMenu);
1064:
1065:                        jif.setJMenuBar(jmb);
1066:
1067:                        return jif;
1068:                    }
1069:                };
1070:                addInternalFrame(desktopPane, internalFrameCreationCmd,
1071:                        new ChainCommand<Component>(new BackgroundColorCommand(
1072:                                Color.yellow), new SetBoundsCommand(
1073:                                new Rectangle(0, 0, 200, 100))));
1074:                addInternalFrame(desktopPane, internalFrameCreationCmd,
1075:                        new ChainCommand<Component>(new BackgroundColorCommand(
1076:                                Color.green), new SetBoundsCommand(
1077:                                new Rectangle(250, 0, 200, 100))));
1078:                addInternalFrame(desktopPane, internalFrameCreationCmd,
1079:                        new ChainCommand<Component>(new BackgroundColorCommand(
1080:                                Color.yellow), new SetBoundsCommand(
1081:                                new Rectangle(0, 150, 200, 100)),
1082:                                new MinimizeInternalFrameCommand()));
1083:                addInternalFrame(desktopPane, internalFrameCreationCmd,
1084:                        new ChainCommand<Component>(new BackgroundColorCommand(
1085:                                Color.green), new SetBoundsCommand(
1086:                                new Rectangle(250, 150, 200, 100)),
1087:                                new MinimizeInternalFrameCommand()));
1088:                desktopPane.setBackground(Color.blue);
1089:
1090:                final JTabbedPane tabbed = new JTabbedPane();
1091:                tabbed.addTab("Buttons", jspButtons);
1092:                tabbed.addTab("Text", jspText);
1093:                tabbed.addTab("Scroll", coloredScrollPane);
1094:                tabbed.addTab("Cells", jspCells);
1095:                tabbed.addTab("Desktop", desktopPane);
1096:                tabbed.addTab("Other", jspOther);
1097:                tabbed.addTab("Yellow", new JPanel());
1098:                tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.yellow);
1099:                tabbed.addTab("Green", new JPanel());
1100:                tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.green);
1101:                tabbed.addTab("Dark Green", new JPanel());
1102:                tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.green
1103:                        .darker());
1104:                tabbed.addTab("Disabled Green", new JPanel());
1105:                tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.green);
1106:                tabbed.setEnabledAt(tabbed.getTabCount() - 1, false);
1107:
1108:                this .add(tabbed, BorderLayout.CENTER);
1109:
1110:                JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT));
1111:                final JCheckBox hasColorization = new JCheckBox("colorize");
1112:                final JSlider colorizationSlider = new JSlider(0, 100, 50);
1113:                colorizationSlider.setEnabled(false);
1114:                hasColorization.addActionListener(new ActionListener() {
1115:                    public void actionPerformed(ActionEvent e) {
1116:                        SwingUtilities.invokeLater(new Runnable() {
1117:                            public void run() {
1118:                                if (hasColorization.isSelected()) {
1119:                                    double val = colorizationSlider.getValue() / 100.0;
1120:                                    ColorizedControlsPanel.this 
1121:                                            .putClientProperty(
1122:                                                    SubstanceLookAndFeel.COLORIZATION_FACTOR,
1123:                                                    new Double(val));
1124:                                } else {
1125:                                    ColorizedControlsPanel.this 
1126:                                            .putClientProperty(
1127:                                                    SubstanceLookAndFeel.COLORIZATION_FACTOR,
1128:                                                    null);
1129:                                }
1130:                                colorizationSlider.setEnabled(hasColorization
1131:                                        .isSelected());
1132:                                tabbed.repaint();
1133:                            }
1134:                        });
1135:                    }
1136:                });
1137:                colorizationSlider.addChangeListener(new ChangeListener() {
1138:                    public void stateChanged(ChangeEvent e) {
1139:                        double val = colorizationSlider.getValue() / 100.0;
1140:                        ColorizedControlsPanel.this .putClientProperty(
1141:                                SubstanceLookAndFeel.COLORIZATION_FACTOR,
1142:                                new Double(val));
1143:                        tabbed.repaint();
1144:                    }
1145:                });
1146:                controls.add(hasColorization);
1147:                controls.add(colorizationSlider);
1148:                this.add(controls, BorderLayout.NORTH);
1149:            }
1150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.