01: /*
02: * Copyright 2005-2008 Kirill Grouchnikov, based on work by
03: * Sun Microsystems, Inc. All rights reserved.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18: */
19: package org.jvnet.substance.swingx;
20:
21: import javax.swing.JComponent;
22: import javax.swing.border.CompoundBorder;
23: import javax.swing.border.EmptyBorder;
24: import javax.swing.plaf.ComponentUI;
25:
26: import org.jdesktop.swingx.JXTitledPanel;
27: import org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI;
28: import org.jvnet.lafwidget.utils.ShadowPopupBorder;
29: import org.jvnet.substance.SubstanceBorder;
30: import org.jvnet.substance.painter.decoration.DecorationAreaType;
31: import org.jvnet.substance.painter.decoration.SubstanceDecorationUtilities;
32:
33: /**
34: * Substance-consistent UI delegate for {@link JXTitledPanel}.
35: *
36: * @author Kirill Grouchnikov
37: */
38: public class SubstanceTitledPanelUI extends BasicTitledPanelUI {
39: public static ComponentUI createUI(JComponent c) {
40: return new SubstanceTitledPanelUI();
41: }
42:
43: /*
44: * (non-Javadoc)
45: *
46: * @see org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI#installUI(javax.swing.JComponent)
47: */
48: @Override
49: public void installUI(JComponent c) {
50: super .installUI(c);
51: JXTitledPanel titledPanel = (JXTitledPanel) c;
52: titledPanel.setBorder(new CompoundBorder(new EmptyBorder(2, 2,
53: 2, 2), new CompoundBorder(ShadowPopupBorder
54: .getInstance(), new SubstanceBorder())));
55: }
56:
57: /*
58: * (non-Javadoc)
59: *
60: * @see org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI#installComponents(org.jdesktop.swingx.JXTitledPanel)
61: */
62: @Override
63: protected void installComponents(JXTitledPanel titledPanel) {
64: super .installComponents(titledPanel);
65: // topPanel.putClientProperty(
66: // SubstanceCoreUtilities.IS_WINDOW_DECORATION_AREA, Boolean.TRUE);
67: SubstanceDecorationUtilities.setDecorationType(topPanel,
68: DecorationAreaType.HEADER);
69: }
70:
71: /*
72: * (non-Javadoc)
73: *
74: * @see org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI#uninstallComponents(org.jdesktop.swingx.JXTitledPanel)
75: */
76: @Override
77: protected void uninstallComponents(JXTitledPanel titledPanel) {
78: // topPanel.putClientProperty(
79: // SubstanceCoreUtilities.IS_WINDOW_DECORATION_AREA, null);
80: SubstanceDecorationUtilities.clearDecorationType(topPanel);
81: super.uninstallComponents(titledPanel);
82: }
83: }
|