001: /*
002: * Copyright (c) 2005-2008 Flamingo / 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 Flamingo 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.ribbon;
031:
032: import java.awt.*;
033: import java.awt.event.ActionEvent;
034: import java.awt.event.ActionListener;
035:
036: import javax.swing.*;
037:
038: import org.jvnet.substance.SubstanceLookAndFeel;
039: import org.jvnet.substance.flamingo.ribbon.gallery.oob.SubstanceRibbonTask;
040: import org.jvnet.substance.utils.SubstanceCoreUtilities;
041:
042: public class NewCheckRibbon extends BasicCheckRibbon {
043: private JLabel saveLabel;
044:
045: public NewCheckRibbon() {
046: super ();
047: }
048:
049: @Override
050: public void configureRibbon() {
051: super .configureRibbon();
052: this .ribbon.addTask("Look & Feel",
053: new SubstanceRibbonTask(this ));
054: }
055:
056: @Override
057: protected void configureControlPanel(JPanel controlPanel) {
058: super .configureControlPanel(controlPanel);
059:
060: final JCheckBox useThemedDefaultIconsCheckBox = new JCheckBox(
061: "Use themed icons");
062: useThemedDefaultIconsCheckBox
063: .setSelected(SubstanceCoreUtilities
064: .useThemedDefaultIcon(null));
065: useThemedDefaultIconsCheckBox
066: .addActionListener(new ActionListener() {
067: public void actionPerformed(ActionEvent e) {
068: SwingUtilities.invokeLater(new Runnable() {
069: public void run() {
070: UIManager
071: .put(
072: SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS,
073: useThemedDefaultIconsCheckBox
074: .isSelected() ? Boolean.TRUE
075: : null);
076: SwingUtilities
077: .updateComponentTreeUI(NewCheckRibbon.this );
078: repaint();
079: }
080: });
081: }
082: });
083: controlPanel.add(useThemedDefaultIconsCheckBox);
084: }
085:
086: public static void main(String[] args) {
087: try {
088: UIManager
089: .setLookAndFeel("org.jvnet.substance.SubstanceLookAndFeel");
090: } catch (Exception e) {
091: e.printStackTrace();
092: }
093: JFrame.setDefaultLookAndFeelDecorated(true);
094:
095: // UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.DEBUG);
096: // JDialog.setDefaultLookAndFeelDecorated(true);
097: // System.setProperty("sun.awt.noerasebackground", "false");
098: SwingUtilities.invokeLater(new Runnable() {
099: public void run() {
100: NewCheckRibbon c = new NewCheckRibbon();
101: c.configureRibbon();
102: // c.addComponentListener(new ComponentAdapter() {
103: // @Override
104: // public void componentResized(ComponentEvent e) {
105: // super.componentResized(e);
106: // ((JFrame) e.getComponent()).getRootPane().repaint();
107: // }
108: // });
109: Rectangle r = GraphicsEnvironment
110: .getLocalGraphicsEnvironment()
111: .getMaximumWindowBounds();
112: c
113: .setPreferredSize(new Dimension(r.width,
114: r.height / 2));
115: c.pack();
116: // center the frame in the physical screen
117: c.setLocation(r.x, r.y);
118: c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
119: c.setVisible(true);
120: }
121: });
122: }
123:
124: }
|