Source Code Cross Referenced for TabControlPanel.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.BorderLayout;
033:        import java.awt.Component;
034:        import java.awt.event.*;
035:        import java.util.*;
036:
037:        import javax.swing.*;
038:
039:        import org.jvnet.lafwidget.LafWidgetUtilities2;
040:        import org.jvnet.lafwidget.utils.LafConstants.TabOverviewKind;
041:        import org.jvnet.substance.*;
042:        import org.jvnet.substance.button.ClassicButtonShaper;
043:        import org.jvnet.substance.theme.*;
044:        import org.jvnet.substance.theme.SubstanceTheme.ThemeKind;
045:        import org.jvnet.substance.utils.SubstanceCoreUtilities;
046:        import org.jvnet.substance.utils.SubstanceConstants.TabContentPaneBorderKind;
047:        import org.jvnet.substance.utils.SubstanceConstants.TabTextAlignmentKind;
048:
049:        import com.jgoodies.forms.builder.PanelBuilder;
050:        import com.jgoodies.forms.layout.CellConstraints;
051:        import com.jgoodies.forms.layout.FormLayout;
052:
053:        /**
054:         * Control panel for the tabbed panes.
055:         * 
056:         * @author Kirill Grouchnikov
057:         */
058:        public class TabControlPanel extends JPanel {
059:            /**
060:             * Tabbed pane.
061:             */
062:            private JTabbedPane jtp;
063:
064:            /**
065:             * Contains the closed components.
066:             */
067:            public LinkedList<Component> closed;
068:
069:            /**
070:             * Model for the combobox that contains the list of all tabs.
071:             * 
072:             * @author Kirill Grouchnikov
073:             */
074:            private static class TabComboBoxModel extends DefaultComboBoxModel {
075:                /**
076:                 * Tabbed pane.
077:                 */
078:                private JTabbedPane jtp;
079:
080:                /**
081:                 * Creates the combobox model.
082:                 * 
083:                 * @param jtp
084:                 *            Tabbed pane.
085:                 */
086:                public TabComboBoxModel(JTabbedPane jtp) {
087:                    this .jtp = jtp;
088:                }
089:
090:                /*
091:                 * (non-Javadoc)
092:                 * 
093:                 * @see javax.swing.DefaultComboBoxModel#getSize()
094:                 */
095:                @Override
096:                public int getSize() {
097:                    return this .jtp.getTabCount();
098:                }
099:
100:                /*
101:                 * (non-Javadoc)
102:                 * 
103:                 * @see javax.swing.DefaultComboBoxModel#getElementAt(int)
104:                 */
105:                @Override
106:                public Object getElementAt(int index) {
107:                    return index;
108:                }
109:
110:                /*
111:                 * (non-Javadoc)
112:                 * 
113:                 * @see javax.swing.DefaultComboBoxModel#getIndexOf(java.lang.Object)
114:                 */
115:                @Override
116:                public int getIndexOf(Object anObject) {
117:                    return (Integer) anObject;
118:                }
119:
120:                /**
121:                 * Fires the event that the combo contents has been changed.
122:                 */
123:                public void changed() {
124:                    this .fireContentsChanged(this , 0, this .getSize() - 1);
125:                }
126:            }
127:
128:            /**
129:             * Cell renderer for the combobox that lists the tabs.
130:             * 
131:             * @author Kirill Grouchnikov
132:             */
133:            private class TabCellRenderer extends JLabel implements 
134:                    ListCellRenderer {
135:                /*
136:                 * (non-Javadoc)
137:                 * 
138:                 * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList,
139:                 *      java.lang.Object, int, boolean, boolean)
140:                 */
141:                public Component getListCellRendererComponent(JList list,
142:                        Object value, int index, boolean isSelected,
143:                        boolean cellHasFocus) {
144:                    if (value == null) {
145:                        this .setText("");
146:                        this .setIcon(null);
147:                    } else {
148:                        this .setText(jtp.getTitleAt((Integer) value));
149:                        this .setIcon(jtp.getIconAt((Integer) value));
150:                    }
151:                    return this ;
152:                }
153:            }
154:
155:            /**
156:             * Returns the contents of the control panel.
157:             * 
158:             * @param jtp
159:             *            Tabbed pane.
160:             * @param mainTabPreviewPainter
161:             *            Tab preview painter.
162:             * @return Control panel contents.
163:             */
164:            private JPanel getContents(final JTabbedPane jtp,
165:                    final MyTabPreviewPainter mainTabPreviewPainter) {
166:                FormLayout lm = new FormLayout(
167:                        "right:pref, 4dlu, fill:min:grow(1), 2dlu, fill:min:grow(1)",
168:                        "p, 2dlu, p, 3dlu, p, 3dlu, p, 3dlu,  p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 7dlu, "
169:                                + "p, 2dlu, p, 0dlu, p, 0dlu, p, 0dlu, p, 7dlu,"
170:                                + "p, 2dlu, p, 3dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 7dlu, "
171:                                + "p, 2dlu, p, 0dlu, p, 0dlu, p, 0dlu, p, 7dlu, "
172:                                + "p, 2dlu, p, 3dlu, p");
173:                lm.setColumnGroups(new int[][] { { 3, 5 } });
174:                PanelBuilder builder = new PanelBuilder(lm);
175:                // builder.setDefaultDialogBorder();
176:                CellConstraints cc = new CellConstraints();
177:
178:                int row = 1;
179:                builder.addSeparator("General", cc.xyw(1, row, 5));
180:
181:                final JComboBox addKindCombo = new JComboBox(new Object[] {
182:                        "regular", "null", "modified" });
183:                JButton addNewTabButton = new JButton("Add");
184:                addNewTabButton.putClientProperty(
185:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
186:                        new ClassicButtonShaper());
187:                addNewTabButton.addActionListener(new ActionListener() {
188:                    public void actionPerformed(ActionEvent e) {
189:                        String selectedKind = (String) addKindCombo
190:                                .getSelectedItem();
191:                        if ("null".equals(selectedKind)) {
192:                            SwingUtilities.invokeLater(new Runnable() {
193:                                public void run() {
194:                                    jtp
195:                                            .addTab(
196:                                                    "null tab",
197:                                                    new ImageIcon(
198:                                                            SubstanceImageCreator
199:                                                                    .getBigHexaMarker(
200:                                                                            0,
201:                                                                            SubstanceLookAndFeel
202:                                                                                    .getTheme())),
203:                                                    null);
204:                                }
205:                            });
206:                            return;
207:                        }
208:
209:                        final int count = 1 + jtp.getTabCount();
210:                        final JComponent tabComp = new NumberedPanel(count);
211:                        if ("modified".equals(selectedKind)) {
212:                            tabComp.putClientProperty(
213:                                    SubstanceLookAndFeel.WINDOW_MODIFIED,
214:                                    Boolean.TRUE);
215:                        }
216:                        SwingUtilities.invokeLater(new Runnable() {
217:                            public void run() {
218:                                jtp.addTab("tab" + count, new ImageIcon(
219:                                        SubstanceImageCreator.getBigHexaMarker(
220:                                                count, SubstanceLookAndFeel
221:                                                        .getTheme())), tabComp);
222:                            }
223:                        });
224:                        SubstanceLookAndFeel
225:                                .registerThemeChangeListener(new ThemeChangeListener() {
226:                                    public void themeChanged() {
227:                                        int index = jtp
228:                                                .indexOfComponent(tabComp);
229:                                        if (index >= 0)
230:                                            jtp
231:                                                    .setIconAt(
232:                                                            index,
233:                                                            SubstanceImageCreator
234:                                                                    .getHexaMarker(
235:                                                                            count,
236:                                                                            SubstanceLookAndFeel
237:                                                                                    .getTheme()));
238:                                    }
239:                                });
240:                    }
241:                });
242:                row += 2;
243:
244:                builder.addLabel("Add tab", cc.xy(1, row));
245:                builder.add(addKindCombo, cc.xy(3, row));
246:                builder.add(addNewTabButton, cc.xy(5, row));
247:
248:                final JComboBox placementCombo = new JComboBox(new Object[] {
249:                        "top", "bottom", "left", "right" });
250:                placementCombo.addActionListener(new ActionListener() {
251:                    public void actionPerformed(ActionEvent e) {
252:                        String selected = (String) placementCombo
253:                                .getSelectedItem();
254:                        if ("top".equals(selected))
255:                            jtp.setTabPlacement(JTabbedPane.TOP);
256:                        if ("bottom".equals(selected))
257:                            jtp.setTabPlacement(JTabbedPane.BOTTOM);
258:                        if ("left".equals(selected))
259:                            jtp.setTabPlacement(JTabbedPane.LEFT);
260:                        if ("right".equals(selected))
261:                            jtp.setTabPlacement(JTabbedPane.RIGHT);
262:                    }
263:                });
264:                row += 2;
265:                builder.addLabel("Placement", cc.xy(1, row));
266:                builder.add(placementCombo, cc.xyw(3, row, 3));
267:
268:                final JComboBox alignmentCombo = new JComboBox(new Object[] {
269:                        TabTextAlignmentKind.DEFAULT,
270:                        TabTextAlignmentKind.ALWAYS_LEFT,
271:                        TabTextAlignmentKind.ALWAYS_RIGHT,
272:                        TabTextAlignmentKind.FOLLOW_PLACEMENT,
273:                        TabTextAlignmentKind.FOLLOW_ORIENTATION });
274:                alignmentCombo
275:                        .setPrototypeDisplayValue(TabTextAlignmentKind.DEFAULT);
276:                alignmentCombo.putClientProperty(
277:                        SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE,
278:                        TabTextAlignmentKind.DEFAULT);
279:                alignmentCombo.addActionListener(new ActionListener() {
280:                    public void actionPerformed(ActionEvent e) {
281:                        TabTextAlignmentKind alignment = (TabTextAlignmentKind) alignmentCombo
282:                                .getSelectedItem();
283:                        jtp
284:                                .putClientProperty(
285:                                        SubstanceLookAndFeel.TABBED_PANE_TEXT_ALIGNMENT_KIND,
286:                                        alignment);
287:                        jtp.repaint();
288:                    }
289:                });
290:                row += 2;
291:                builder.addLabel("Alignment", cc.xy(1, row));
292:                builder.add(alignmentCombo, cc.xyw(3, row, 3));
293:
294:                try {
295:                    final JComboBox overviewKindCombo = new JComboBox(
296:                            new Object[] { TabOverviewKind.GRID,
297:                                    TabOverviewKind.MENU_CAROUSEL,
298:                                    TabOverviewKind.ROUND_CAROUSEL });
299:                    overviewKindCombo.setSelectedItem(LafWidgetUtilities2
300:                            .getTabPreviewPainter(jtp).getOverviewKind(jtp));
301:                    overviewKindCombo.addActionListener(new ActionListener() {
302:                        public void actionPerformed(ActionEvent e) {
303:                            mainTabPreviewPainter
304:                                    .setTabOverviewKind((TabOverviewKind) overviewKindCombo
305:                                            .getSelectedItem());
306:                        }
307:                    });
308:                    overviewKindCombo
309:                            .setRenderer(new SubstanceDefaultComboBoxRenderer(
310:                                    overviewKindCombo) {
311:                                @Override
312:                                public Component getListCellRendererComponent(
313:                                        JList list, Object value, int index,
314:                                        boolean isSelected, boolean cellHasFocus) {
315:                                    TabOverviewKind kind = (TabOverviewKind) value;
316:                                    return super .getListCellRendererComponent(
317:                                            list, kind.getName(), index,
318:                                            isSelected, cellHasFocus);
319:                                }
320:                            });
321:                    row += 2;
322:                    builder.addLabel("Overview kind", cc.xy(1, row));
323:                    builder.add(overviewKindCombo, cc.xyw(3, row, 3));
324:                } catch (NoClassDefFoundError ncdfe) {
325:                }
326:
327:                row += 2;
328:                builder.addLabel("Composite", cc.xy(1, row));
329:                builder.add(new BackgroundCompositeCombo(jtp), cc
330:                        .xyw(3, row, 3));
331:
332:                final JCheckBox useScrollLayout = new JCheckBox(
333:                        "Uses scroll layout");
334:                useScrollLayout.setSelected(false);
335:                useScrollLayout.addActionListener(new ActionListener() {
336:                    public void actionPerformed(ActionEvent e) {
337:                        jtp
338:                                .setTabLayoutPolicy(useScrollLayout
339:                                        .isSelected() ? JTabbedPane.SCROLL_TAB_LAYOUT
340:                                        : JTabbedPane.WRAP_TAB_LAYOUT);
341:                    }
342:                });
343:                row += 2;
344:                builder.addLabel("Layout", cc.xy(1, row));
345:                builder.add(useScrollLayout, cc.xyw(3, row, 3));
346:
347:                final JComboBox contentBorderCombo = new JComboBox(
348:                        new Object[] { TabContentPaneBorderKind.DOUBLE_FULL,
349:                                TabContentPaneBorderKind.SINGLE_FULL,
350:                                TabContentPaneBorderKind.DOUBLE_PLACEMENT,
351:                                TabContentPaneBorderKind.SINGLE_PLACEMENT });
352:                contentBorderCombo.setSelectedItem(SubstanceCoreUtilities
353:                        .getContentBorderKind(jtp));
354:                contentBorderCombo.addActionListener(new ActionListener() {
355:                    public void actionPerformed(ActionEvent e) {
356:                        TabContentPaneBorderKind contentBorderKind = (TabContentPaneBorderKind) contentBorderCombo
357:                                .getSelectedItem();
358:                        jtp
359:                                .putClientProperty(
360:                                        SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
361:                                        contentBorderKind);
362:                        jtp.updateUI();
363:                        jtp.repaint();
364:                    }
365:                });
366:                row += 2;
367:                builder.addLabel("Content border", cc.xy(1, row));
368:                builder.add(contentBorderCombo, cc.xyw(3, row, 3));
369:
370:                JButton enableAll = new JButton("+ all");
371:                enableAll.putClientProperty(
372:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
373:                        new ClassicButtonShaper());
374:                enableAll.addActionListener(new ActionListener() {
375:                    public void actionPerformed(ActionEvent e) {
376:                        for (int i = 0; i < jtp.getTabCount(); i++) {
377:                            jtp.setEnabledAt(i, true);
378:                        }
379:                    }
380:                });
381:
382:                JButton disableAll = new JButton("- all");
383:                disableAll.putClientProperty(
384:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
385:                        new ClassicButtonShaper());
386:                disableAll.addActionListener(new ActionListener() {
387:                    public void actionPerformed(ActionEvent e) {
388:                        for (int i = 0; i < jtp.getTabCount(); i++) {
389:                            jtp.setEnabledAt(i, false);
390:                        }
391:                    }
392:                });
393:
394:                row += 2;
395:                builder.addLabel("Enable all", cc.xy(1, row));
396:                builder.add(enableAll, cc.xy(3, row));
397:                builder.add(disableAll, cc.xy(5, row));
398:
399:                JButton closeAllEnabled = new JButton("Close");
400:                closeAllEnabled.putClientProperty(
401:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
402:                        new ClassicButtonShaper());
403:                closeAllEnabled.addActionListener(new ActionListener() {
404:                    public void actionPerformed(ActionEvent e) {
405:                        Set<Component> toRemove = new HashSet<Component>();
406:                        for (int i = 0; i < jtp.getTabCount(); i++) {
407:                            if (jtp.isEnabledAt(i))
408:                                toRemove.add(jtp.getComponentAt(i));
409:                        }
410:                        for (Component comp : toRemove)
411:                            jtp.remove(comp);
412:                    }
413:                });
414:
415:                JButton restoreClosed = new JButton("Restore");
416:                restoreClosed.putClientProperty(
417:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
418:                        new ClassicButtonShaper());
419:                restoreClosed.addActionListener(new ActionListener() {
420:                    public void actionPerformed(ActionEvent e) {
421:                        for (Component tnp : closed) {
422:                            jtp.addTab("restored", tnp);
423:                        }
424:                    }
425:                });
426:
427:                row += 2;
428:                builder.addLabel("Close all", cc.xy(1, row));
429:                builder.add(closeAllEnabled, cc.xy(3, row));
430:                builder.add(restoreClosed, cc.xy(5, row));
431:
432:                row += 2;
433:                builder.addSeparator("General Theme", cc.xyw(1, row, 5));
434:
435:                ButtonGroup paneThemeGroup = new ButtonGroup();
436:                final JRadioButton paneNoThemeRb = new JRadioButton("Global");
437:                paneNoThemeRb.setSelected(true);
438:                final JRadioButton paneBarbyPinkThemeRb = new JRadioButton(
439:                        "Barby Pink");
440:                final JRadioButton paneComplexThemeRb = new JRadioButton(
441:                        "Custom complex");
442:                paneThemeGroup.add(paneNoThemeRb);
443:                paneThemeGroup.add(paneBarbyPinkThemeRb);
444:                paneThemeGroup.add(paneComplexThemeRb);
445:                paneNoThemeRb.addActionListener(new ActionListener() {
446:                    public void actionPerformed(ActionEvent e) {
447:                        jtp.putClientProperty(
448:                                SubstanceLookAndFeel.THEME_PROPERTY, null);
449:                        jtp.repaint();
450:                    }
451:                });
452:                paneBarbyPinkThemeRb.addActionListener(new ActionListener() {
453:                    public void actionPerformed(ActionEvent e) {
454:                        jtp.putClientProperty(
455:                                SubstanceLookAndFeel.THEME_PROPERTY,
456:                                new SubstanceBarbyPinkTheme());
457:                        jtp.repaint();
458:                    }
459:                });
460:                paneComplexThemeRb.addActionListener(new ActionListener() {
461:                    public void actionPerformed(ActionEvent e) {
462:                        jtp.putClientProperty(
463:                                SubstanceLookAndFeel.THEME_PROPERTY,
464:                                new SubstanceComplexTheme("Test theme",
465:                                        ThemeKind.BRIGHT,
466:                                        new SubstanceBottleGreenTheme(),
467:                                        new SubstanceLimeGreenTheme(),
468:                                        new SubstancePurpleTheme(),
469:                                        new SubstanceBottleGreenTheme()));
470:                        jtp.repaint();
471:                    }
472:                });
473:
474:                row += 2;
475:                builder.addLabel("Theme", cc.xy(1, row));
476:                builder.add(paneNoThemeRb, cc.xyw(3, row, 3));
477:                row += 2;
478:                builder.add(paneBarbyPinkThemeRb, cc.xyw(3, row, 3));
479:                row += 2;
480:                builder.add(paneComplexThemeRb, cc.xyw(3, row, 3));
481:
482:                final JCheckBox paintActiveTheme = new JCheckBox("Paint active");
483:                paintActiveTheme.setSelected(false);
484:                paintActiveTheme.addActionListener(new ActionListener() {
485:                    public void actionPerformed(ActionEvent e) {
486:                        jtp.putClientProperty(
487:                                SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY,
488:                                (paintActiveTheme.isSelected() ? Boolean.TRUE
489:                                        : null));
490:                        jtp.repaint();
491:                    }
492:                });
493:
494:                row += 2;
495:                builder.addLabel("Active", cc.xy(1, row));
496:                builder.add(paintActiveTheme, cc.xyw(3, row, 3));
497:
498:                row += 2;
499:                builder.addSeparator("Single Tab", cc.xyw(1, row, 5));
500:
501:                final JComboBox tabSelectorCombo = new JComboBox(
502:                        new TabComboBoxModel(this .jtp));
503:                tabSelectorCombo.setRenderer(new TabCellRenderer());
504:                jtp.addContainerListener(new ContainerAdapter() {
505:                    @Override
506:                    public void componentAdded(ContainerEvent e) {
507:                        ((TabComboBoxModel) tabSelectorCombo.getModel())
508:                                .changed();
509:                    }
510:
511:                    @Override
512:                    public void componentRemoved(ContainerEvent e) {
513:                        ((TabComboBoxModel) tabSelectorCombo.getModel())
514:                                .changed();
515:                    }
516:                });
517:
518:                row += 2;
519:                builder.addLabel("Select", cc.xy(1, row));
520:                builder.add(tabSelectorCombo, cc.xyw(3, row, 3));
521:
522:                final JCheckBox markAsModified = new JCheckBox(
523:                        "Marked modified");
524:                markAsModified.setSelected(false);
525:                markAsModified.addActionListener(new ActionListener() {
526:                    public void actionPerformed(ActionEvent e) {
527:                        if (tabSelectorCombo.getSelectedItem() == null)
528:                            return;
529:                        Component comp = jtp
530:                                .getComponentAt((Integer) tabSelectorCombo
531:                                        .getSelectedItem());
532:                        if ((comp != null) && (comp instanceof  JComponent)) {
533:                            JComponent jc = (JComponent) comp;
534:                            jc.putClientProperty(
535:                                    SubstanceLookAndFeel.WINDOW_MODIFIED,
536:                                    (markAsModified.isSelected() ? Boolean.TRUE
537:                                            : false));
538:                        }
539:                    }
540:                });
541:                tabSelectorCombo.addItemListener(new ItemListener() {
542:                    public void itemStateChanged(ItemEvent e) {
543:                        Component selComp = jtp
544:                                .getComponentAt((Integer) tabSelectorCombo
545:                                        .getSelectedItem());
546:                        if ((selComp != null)
547:                                && (selComp instanceof  JComponent)) {
548:                            JComponent selected = (JComponent) selComp;
549:                            markAsModified
550:                                    .setSelected(Boolean.TRUE
551:                                            .equals(selected
552:                                                    .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)));
553:                        }
554:                    }
555:                });
556:                row += 2;
557:                builder.addLabel("Modified", cc.xy(1, row));
558:                builder.add(markAsModified, cc.xyw(3, row, 3));
559:
560:                final JCheckBox isModifiedAnimOnClose = new JCheckBox(
561:                        "Animation on X");
562:                isModifiedAnimOnClose.setSelected(false);
563:                isModifiedAnimOnClose.addActionListener(new ActionListener() {
564:                    public void actionPerformed(ActionEvent e) {
565:                        if (tabSelectorCombo.getSelectedItem() == null)
566:                            return;
567:                        Component comp = jtp
568:                                .getComponentAt((Integer) tabSelectorCombo
569:                                        .getSelectedItem());
570:                        if ((comp != null) && (comp instanceof  JComponent)) {
571:                            JComponent jc = (JComponent) comp;
572:                            jc
573:                                    .putClientProperty(
574:                                            SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION,
575:                                            (isModifiedAnimOnClose.isSelected() ? Boolean.TRUE
576:                                                    : null));
577:                        }
578:                    }
579:                });
580:                tabSelectorCombo.addItemListener(new ItemListener() {
581:                    public void itemStateChanged(ItemEvent e) {
582:                        Component selComp = jtp
583:                                .getComponentAt((Integer) tabSelectorCombo
584:                                        .getSelectedItem());
585:                        if ((selComp != null)
586:                                && (selComp instanceof  JComponent)) {
587:                            JComponent selected = (JComponent) selComp;
588:                            isModifiedAnimOnClose
589:                                    .setSelected(Boolean.TRUE
590:                                            .equals(selected
591:                                                    .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION)));
592:                        }
593:                    }
594:                });
595:                row += 2;
596:                builder.add(isModifiedAnimOnClose, cc.xyw(3, row, 3));
597:
598:                final JCheckBox hasCloseButton = new JCheckBox(
599:                        "No close button");
600:                hasCloseButton.setSelected(false);
601:                hasCloseButton.addActionListener(new ActionListener() {
602:                    public void actionPerformed(ActionEvent e) {
603:                        if (tabSelectorCombo.getSelectedItem() == null)
604:                            return;
605:                        Component comp = jtp
606:                                .getComponentAt((Integer) tabSelectorCombo
607:                                        .getSelectedItem());
608:                        if ((comp != null) && (comp instanceof  JComponent)) {
609:                            JComponent jc = (JComponent) comp;
610:                            jc
611:                                    .putClientProperty(
612:                                            SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY,
613:                                            (hasCloseButton.isSelected() ? Boolean.FALSE
614:                                                    : null));
615:                            jtp.repaint();
616:                        }
617:                    }
618:                });
619:                tabSelectorCombo.addItemListener(new ItemListener() {
620:                    public void itemStateChanged(ItemEvent e) {
621:                        Component selComp = jtp
622:                                .getComponentAt((Integer) tabSelectorCombo
623:                                        .getSelectedItem());
624:                        if ((selComp != null)
625:                                && (selComp instanceof  JComponent)) {
626:                            JComponent selected = (JComponent) selComp;
627:                            hasCloseButton
628:                                    .setSelected(Boolean.FALSE
629:                                            .equals(selected
630:                                                    .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY)));
631:                        }
632:                    }
633:                });
634:
635:                JButton closeButton = new JButton("Close");
636:                closeButton.putClientProperty(
637:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
638:                        new ClassicButtonShaper());
639:                closeButton.addActionListener(new ActionListener() {
640:                    public void actionPerformed(ActionEvent e) {
641:                        SwingUtilities.invokeLater(new Runnable() {
642:                            public void run() {
643:                                if (tabSelectorCombo.getSelectedItem() == null)
644:                                    return;
645:                                Component comp = jtp
646:                                        .getComponentAt((Integer) tabSelectorCombo
647:                                                .getSelectedItem());
648:                                jtp.removeTabAt((Integer) tabSelectorCombo
649:                                        .getSelectedItem());
650:                                closed.add(comp);
651:                                jtp.repaint();
652:                            }
653:                        });
654:                    }
655:                });
656:
657:                JButton selectButton = new JButton("Select");
658:                selectButton.putClientProperty(
659:                        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
660:                        new ClassicButtonShaper());
661:                selectButton.addActionListener(new ActionListener() {
662:                    public void actionPerformed(ActionEvent e) {
663:                        SwingUtilities.invokeLater(new Runnable() {
664:                            public void run() {
665:                                if (tabSelectorCombo.getSelectedItem() == null)
666:                                    return;
667:                                jtp.setSelectedIndex((Integer) tabSelectorCombo
668:                                        .getSelectedItem());
669:                            }
670:                        });
671:                    }
672:                });
673:                row += 2;
674:                builder.addLabel("Tab op", cc.xy(1, row));
675:                builder.add(closeButton, cc.xy(3, row));
676:                builder.add(selectButton, cc.xy(5, row));
677:
678:                row += 2;
679:                builder.addSeparator("Theme Single", cc.xyw(1, row, 5));
680:
681:                ButtonGroup tabThemeGroup = new ButtonGroup();
682:                final JRadioButton tabNoThemeRb = new JRadioButton("Global");
683:                tabNoThemeRb.setSelected(true);
684:                final JRadioButton tabBarbyPinkThemeRb = new JRadioButton(
685:                        "Barby Pink");
686:                final JRadioButton tabComplexThemeRb = new JRadioButton(
687:                        "Custom complex");
688:                tabThemeGroup.add(tabNoThemeRb);
689:                tabThemeGroup.add(tabBarbyPinkThemeRb);
690:                tabThemeGroup.add(tabComplexThemeRb);
691:                tabNoThemeRb.addActionListener(new ActionListener() {
692:                    public void actionPerformed(ActionEvent e) {
693:                        if (tabSelectorCombo.getSelectedItem() == null)
694:                            return;
695:                        Component comp = jtp
696:                                .getComponentAt((Integer) tabSelectorCombo
697:                                        .getSelectedItem());
698:                        if ((comp != null) && (comp instanceof  JComponent)) {
699:                            JComponent jc = (JComponent) comp;
700:                            jc.putClientProperty(
701:                                    SubstanceLookAndFeel.THEME_PROPERTY, null);
702:                            jtp.repaint();
703:                        }
704:                    }
705:                });
706:                tabBarbyPinkThemeRb.addActionListener(new ActionListener() {
707:                    public void actionPerformed(ActionEvent e) {
708:                        if (tabSelectorCombo.getSelectedItem() == null)
709:                            return;
710:                        Component comp = jtp
711:                                .getComponentAt((Integer) tabSelectorCombo
712:                                        .getSelectedItem());
713:                        if ((comp != null) && (comp instanceof  JComponent)) {
714:                            JComponent jc = (JComponent) comp;
715:                            jc.putClientProperty(
716:                                    SubstanceLookAndFeel.THEME_PROPERTY,
717:                                    new SubstanceBarbyPinkTheme());
718:                            jtp.repaint();
719:                        }
720:                    }
721:                });
722:                tabComplexThemeRb.addActionListener(new ActionListener() {
723:                    public void actionPerformed(ActionEvent e) {
724:                        if (tabSelectorCombo.getSelectedItem() == null)
725:                            return;
726:                        Component comp = jtp
727:                                .getComponentAt((Integer) tabSelectorCombo
728:                                        .getSelectedItem());
729:                        if ((comp != null) && (comp instanceof  JComponent)) {
730:                            JComponent jc = (JComponent) comp;
731:                            jc.putClientProperty(
732:                                    SubstanceLookAndFeel.THEME_PROPERTY,
733:                                    new SubstanceComplexTheme("Test theme",
734:                                            ThemeKind.BRIGHT,
735:                                            new SubstanceBottleGreenTheme(),
736:                                            new SubstanceLimeGreenTheme(),
737:                                            new SubstancePurpleTheme(),
738:                                            new SubstanceBottleGreenTheme()));
739:                            jtp.repaint();
740:                        }
741:                    }
742:                });
743:                tabSelectorCombo.addItemListener(new ItemListener() {
744:                    public void itemStateChanged(ItemEvent e) {
745:                        Component selComp = jtp
746:                                .getComponentAt((Integer) tabSelectorCombo
747:                                        .getSelectedItem());
748:                        if ((selComp != null)
749:                                && (selComp instanceof  JComponent)) {
750:                            JComponent selected = (JComponent) selComp;
751:                            Object obj = selected
752:                                    .getClientProperty(SubstanceLookAndFeel.THEME_PROPERTY);
753:                            if (obj == null) {
754:                                tabNoThemeRb.setSelected(true);
755:                                return;
756:                            }
757:                            if (obj instanceof  SubstanceBarbyPinkTheme) {
758:                                tabBarbyPinkThemeRb.setSelected(true);
759:                                return;
760:                            }
761:
762:                            tabComplexThemeRb.setSelected(true);
763:                        }
764:                    }
765:                });
766:
767:                row += 2;
768:                builder.addLabel("Theme", cc.xy(1, row));
769:                builder.add(tabNoThemeRb, cc.xyw(3, row, 3));
770:                row += 2;
771:                builder.add(tabBarbyPinkThemeRb, cc.xyw(3, row, 3));
772:                row += 2;
773:                builder.add(tabComplexThemeRb, cc.xyw(3, row, 3));
774:
775:                final JCheckBox paintTabAsActive = new JCheckBox("Paint active");
776:                paintTabAsActive.setSelected(false);
777:                paintTabAsActive.addActionListener(new ActionListener() {
778:                    public void actionPerformed(ActionEvent e) {
779:                        if (tabSelectorCombo.getSelectedItem() == null)
780:                            return;
781:                        Component comp = jtp
782:                                .getComponentAt((Integer) tabSelectorCombo
783:                                        .getSelectedItem());
784:                        if ((comp != null) && (comp instanceof  JComponent)) {
785:                            JComponent jc = (JComponent) comp;
786:                            jc
787:                                    .putClientProperty(
788:                                            SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY,
789:                                            (paintTabAsActive.isSelected() ? Boolean.TRUE
790:                                                    : null));
791:                            jtp.repaint();
792:                        }
793:                    }
794:                });
795:                tabSelectorCombo.addItemListener(new ItemListener() {
796:                    public void itemStateChanged(ItemEvent e) {
797:                        Component selComp = jtp
798:                                .getComponentAt((Integer) tabSelectorCombo
799:                                        .getSelectedItem());
800:                        if ((selComp != null)
801:                                && (selComp instanceof  JComponent)) {
802:                            JComponent selected = (JComponent) selComp;
803:                            paintTabAsActive
804:                                    .setSelected(Boolean.TRUE
805:                                            .equals(selected
806:                                                    .getClientProperty(SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY)));
807:                        }
808:                    }
809:                });
810:                row += 2;
811:                builder.addLabel("Active", cc.xy(1, row));
812:                builder.add(paintTabAsActive, cc.xyw(3, row, 3));
813:
814:                row += 2;
815:                builder.addSeparator("Close Button Single", cc.xyw(1, row, 5));
816:
817:                row += 2;
818:                builder.addLabel("Visible", cc.xy(1, row));
819:                builder.add(hasCloseButton, cc.xyw(3, row, 3));
820:
821:                return builder.getPanel();
822:            }
823:
824:            /**
825:             * Creates the tab control panel.
826:             * 
827:             * @param jtp
828:             *            Tabbed pane.
829:             * @param previewPainter
830:             *            Preview painter.
831:             */
832:            public TabControlPanel(JTabbedPane jtp,
833:                    MyTabPreviewPainter previewPainter) {
834:                super ();
835:                this .jtp = jtp;
836:                this .closed = new LinkedList<Component>();
837:
838:                this .setLayout(new BorderLayout());
839:                JPanel contents = getContents(jtp, previewPainter);
840:                contents.setOpaque(false);
841:                contents.putClientProperty(
842:                        SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY,
843:                        Boolean.TRUE);
844:                this .add(contents, BorderLayout.CENTER);
845:            }
846:
847:            // @Override
848:            // public Dimension getPreferredSize() {
849:            // Dimension result = super.getPreferredSize();
850:            // return new Dimension(190, result.height);
851:            // }
852:            //
853:            // private class TabControlPanelLayout implements LayoutManager {
854:            // public void addLayoutComponent(String name, Component comp) {
855:            // }
856:            //
857:            // public void removeLayoutComponent(Component comp) {
858:            // }
859:            //
860:            // public void layoutContainer(Container parent) {
861:            // Insets pIns = paneControls.getInsets();
862:            // Insets tIns = tabControls.getInsets();
863:            // int width = Math.max(paneControls.getPreferredSize().width
864:            // + pIns.left + pIns.right,
865:            // tabControls.getPreferredSize().width + tIns.left
866:            // + tIns.right);
867:            // width = Math.min(parent.getWidth(), width);
868:            //
869:            // int h = paneControls.getPreferredSize().height + pIns.top
870:            // + pIns.bottom;
871:            // paneControls.setBounds(0, 0, width, h);
872:            //
873:            // tabControls.setBounds(0, h, width,
874:            // tabControls.getPreferredSize().height + tIns.top
875:            // + tIns.bottom);
876:            // }
877:            //
878:            // public Dimension minimumLayoutSize(Container parent) {
879:            // int w = Math.max(tabControls.getMinimumSize().width, paneControls
880:            // .getMinimumSize().width);
881:            // Insets tIns = tabControls.getInsets();
882:            // Insets pIns = paneControls.getInsets();
883:            // int h = tabControls.getMinimumSize().height
884:            // + paneControls.getMinimumSize().height + tIns.top
885:            // + tIns.bottom + pIns.top + pIns.bottom;
886:            // return new Dimension(w, h);
887:            // }
888:            //
889:            // public Dimension preferredLayoutSize(Container parent) {
890:            // int w = Math.max(tabControls.getPreferredSize().width, paneControls
891:            // .getPreferredSize().width);
892:            // Insets tIns = tabControls.getInsets();
893:            // Insets pIns = paneControls.getInsets();
894:            // int h = tabControls.getPreferredSize().height
895:            // + paneControls.getPreferredSize().height + tIns.top
896:            // + tIns.bottom + pIns.top + pIns.bottom;
897:            // return new Dimension(w, h);
898:            // }
899:            // }
900:            //
901:            // private void addSeparator(JPanel panel, String text) {
902:            // JLabel l = new JLabel(text, SwingConstants.LEADING);
903:            // l.setFont(l.getFont().deriveFont(Font.BOLD));
904:            //
905:            // panel.add(l, "gapbottom 1,gaptop para, span, split 2");
906:            // panel.add(new JSeparator(), "gapleft rel, gaptop para, growx");
907:            // }
908:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.