Debian Codegraph @

substance-swingx/src/main/java/org/pushingpixels/substance/swingx/SubstanceTitledPanelUI.java

raw symbols SCIP
1 /*
2 * Copyright 2005-2010 Kirill Grouchnikov, based on work by
3 * Sun Microsystems, Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
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.pushingpixels.substance.swingx;
20
21 import javax.swing.JComponent;
22 import javax.swing.border.*;
23 import javax.swing.plaf.*;
24
25 import org.jdesktop.swingx.JXPanel;
26 import org.jdesktop.swingx.JXTitledPanel;
27 import org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI;
28 import org.pushingpixels.lafwidget.utils.ShadowPopupBorder;
29 import org.pushingpixels.substance.api.DecorationAreaType;
30 import org.pushingpixels.substance.api.SubstanceLookAndFeel;
31 import org.pushingpixels.substance.internal.painter.DecorationPainterUtils;
32 import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
33 import org.pushingpixels.substance.internal.utils.border.SubstanceBorder;
34
35 /**
36 * Substance-consistent UI delegate for {@link JXTitledPanel}.
37 *
38 * @author Kirill Grouchnikov
39 */
40 public class SubstanceTitledPanelUI extends BasicTitledPanelUI {
41 public static ComponentUI createUI(JComponent comp) {
42 SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp);
43 return new SubstanceTitledPanelUI();
44 }
45
46 /*
47 * (non-Javadoc)
48 *
49 * @see
50 * org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI#installComponents(org
51 * .jdesktop.swingx.JXTitledPanel)
52 */
53 @Override
54 protected void installComponents(JXTitledPanel titledPanel) {
55 super.installComponents(titledPanel);
56
57 Border currBorder = titledPanel.getBorder();
58 if ((currBorder == null) || (currBorder instanceof UIResource)) {
59 titledPanel
60 .setBorder(new BorderUIResource.CompoundBorderUIResource(
61 new EmptyBorder(2, 2, 2, 2), new CompoundBorder(
62 ShadowPopupBorder.getInstance(),
63 new SubstanceBorder())));
64 }
65 }
66
67 /*
68 * (non-Javadoc)
69 *
70 * @see
71 * org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI#createAndConfigureTopPanel
72 * (org.jdesktop.swingx.JXTitledPanel)
73 */
74 @Override
75 protected JXPanel createAndConfigureTopPanel(JXTitledPanel titledPanel) {
76 JXPanel result = super.createAndConfigureTopPanel(titledPanel);
77 SubstanceLookAndFeel.setDecorationType(result,
78 DecorationAreaType.HEADER);
79 return result;
80 }
81
82 /*
83 * (non-Javadoc)
84 *
85 * @see
86 * org.jdesktop.swingx.plaf.basic.BasicTitledPanelUI#uninstallDefaults(org
87 * .jdesktop.swingx.JXTitledPanel)
88 */
89 @Override
90 protected void uninstallDefaults(JXTitledPanel titledPanel) {
91 DecorationPainterUtils.clearDecorationType(topPanel);
92 super.uninstallDefaults(titledPanel);
93 }
94 }