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:
034: import javax.swing.*;
035:
036: import org.jvnet.lafwidget.LafWidget;
037: import org.jvnet.substance.SubstanceImageCreator;
038: import org.jvnet.substance.SubstanceLookAndFeel;
039: import org.jvnet.substance.theme.ThemeChangeListener;
040:
041: /**
042: * Test application panel for testing {@link JTabbedPane} component.
043: *
044: * @author Kirill Grouchnikov
045: */
046: public class TabPanel extends ControllablePanel {
047: /**
048: * Tabbed pane.
049: */
050: public JTabbedPane jtp;
051:
052: /**
053: * Creates a test panel with tabbed pane.
054: */
055: public TabPanel() {
056: this .setLayout(new BorderLayout());
057: jtp = new JTabbedPane();
058: NumberedPanel tnp1 = new NumberedPanel(1);
059: tnp1
060: .putClientProperty(
061: SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS,
062: Boolean.TRUE);
063: jtp.addTab("tab0", null, new JPanel());
064: jtp.addTab("tab1", SubstanceImageCreator.getThemeIcon(null),
065: tnp1);
066: jtp.addTab("tab 2", SubstanceImageCreator.getThemeIcon(null),
067: new NumberedPanel(2));
068: NumberedPanel tnp3 = new NumberedPanel(3);
069: tnp3
070: .putClientProperty(
071: SubstanceLookAndFeel.TABBED_PANE_VERTICAL_ORIENTATION_ROTATE_ICONS,
072: Boolean.TRUE);
073: jtp.addTab("tab 3", SubstanceImageCreator.getThemeIcon(null),
074: tnp3);
075: final NumberedPanel np4 = new NumberedPanel(4);
076: jtp.addTab("tab 4", new ImageIcon(SubstanceImageCreator
077: .getBigHexaMarker(4, SubstanceLookAndFeel.getTheme())),
078: np4);
079: final NumberedPanel np5 = new NumberedPanel(5);
080: jtp.addTab("tab 5", new ImageIcon(SubstanceImageCreator
081: .getBigHexaMarker(5, SubstanceLookAndFeel.getTheme())),
082: np5);
083: SubstanceLookAndFeel
084: .registerThemeChangeListener(new ThemeChangeListener() {
085: public void themeChanged() {
086: int index4 = jtp.indexOfComponent(np4);
087: if (index4 >= 0) {
088: jtp.setIconAt(index4, SubstanceImageCreator
089: .getHexaMarker(4,
090: SubstanceLookAndFeel
091: .getTheme()));
092: }
093: int index5 = jtp.indexOfComponent(np5);
094: if (index5 >= 0) {
095: jtp.setIconAt(index5, SubstanceImageCreator
096: .getHexaMarker(5,
097: SubstanceLookAndFeel
098: .getTheme()));
099: }
100: }
101: });
102:
103: jtp.setEnabledAt(2, false);
104: jtp.setEnabledAt(3, false);
105: this .add(jtp, BorderLayout.CENTER);
106:
107: try {
108: MyTabPreviewPainter previewPainter = new MyTabPreviewPainter();
109: jtp.putClientProperty(
110: LafWidget.TABBED_PANE_PREVIEW_PAINTER,
111: previewPainter);
112: this .controlPanel = new TabControlPanel(jtp, previewPainter);
113: } catch (NoClassDefFoundError ncdfe) {
114: this .controlPanel = new TabControlPanel(jtp, null);
115: } catch (Throwable e) {
116: }
117:
118: // this.setPreferredSize(new Dimension(400, 400));
119: // this.setSize(this.getPreferredSize());
120: // this.setMinimumSize(this.getPreferredSize());
121: }
122:
123: }
|