author | weijun |
Thu, 11 Dec 2014 15:19:12 +0800 | |
changeset 28228 | be83f404724d |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
25761
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.plaf.basic; |
|
27 |
||
28 |
import java.awt.*; |
|
29 |
import javax.swing.*; |
|
30 |
import javax.swing.border.*; |
|
31 |
import javax.swing.plaf.*; |
|
32 |
import java.awt.*; |
|
33 |
import java.awt.event.*; |
|
34 |
||
35 |
||
36 |
/** |
|
37 |
* BasicPanel implementation |
|
38 |
* |
|
39 |
* @author Steve Wilson |
|
40 |
*/ |
|
41 |
public class BasicPanelUI extends PanelUI { |
|
42 |
||
43 |
// Shared UI object |
|
44 |
private static PanelUI panelUI; |
|
45 |
||
25761
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
46 |
/** |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
47 |
* Returns an instance of {@code BasicPanelUI}. |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
48 |
* |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
49 |
* @param c a component |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
50 |
* @return an instance of {@code BasicPanelUI} |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
51 |
*/ |
2 | 52 |
public static ComponentUI createUI(JComponent c) { |
53 |
if(panelUI == null) { |
|
54 |
panelUI = new BasicPanelUI(); |
|
55 |
} |
|
56 |
return panelUI; |
|
57 |
} |
|
58 |
||
59 |
public void installUI(JComponent c) { |
|
60 |
JPanel p = (JPanel)c; |
|
61 |
super.installUI(p); |
|
62 |
installDefaults(p); |
|
63 |
} |
|
64 |
||
65 |
public void uninstallUI(JComponent c) { |
|
66 |
JPanel p = (JPanel)c; |
|
67 |
uninstallDefaults(p); |
|
68 |
super.uninstallUI(c); |
|
69 |
} |
|
70 |
||
25761
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
71 |
/** |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
72 |
* Method for installing panel properties. |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
73 |
* |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
74 |
* @param p an instance of {@code JPanel} |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
75 |
*/ |
2 | 76 |
protected void installDefaults(JPanel p) { |
77 |
LookAndFeel.installColorsAndFont(p, |
|
78 |
"Panel.background", |
|
79 |
"Panel.foreground", |
|
80 |
"Panel.font"); |
|
81 |
LookAndFeel.installBorder(p,"Panel.border"); |
|
82 |
LookAndFeel.installProperty(p, "opaque", Boolean.TRUE); |
|
83 |
} |
|
84 |
||
25761
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
85 |
/** |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
86 |
* Method for uninstalling panel properties. |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
87 |
* |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
88 |
* @param p an instance of {@code JPanel} |
c408b10ef757
8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents:
5506
diff
changeset
|
89 |
*/ |
2 | 90 |
protected void uninstallDefaults(JPanel p) { |
91 |
LookAndFeel.uninstallBorder(p); |
|
92 |
} |
|
93 |
||
94 |
||
95 |
/** |
|
96 |
* Returns the baseline. |
|
97 |
* |
|
98 |
* @throws NullPointerException {@inheritDoc} |
|
99 |
* @throws IllegalArgumentException {@inheritDoc} |
|
100 |
* @see javax.swing.JComponent#getBaseline(int, int) |
|
101 |
* @since 1.6 |
|
102 |
*/ |
|
103 |
public int getBaseline(JComponent c, int width, int height) { |
|
104 |
super.getBaseline(c, width, height); |
|
105 |
Border border = c.getBorder(); |
|
106 |
if (border instanceof AbstractBorder) { |
|
107 |
return ((AbstractBorder)border).getBaseline(c, width, height); |
|
108 |
} |
|
109 |
return -1; |
|
110 |
} |
|
111 |
||
112 |
/** |
|
113 |
* Returns an enum indicating how the baseline of the component |
|
114 |
* changes as the size changes. |
|
115 |
* |
|
116 |
* @throws NullPointerException {@inheritDoc} |
|
117 |
* @see javax.swing.JComponent#getBaseline(int, int) |
|
118 |
* @since 1.6 |
|
119 |
*/ |
|
120 |
public Component.BaselineResizeBehavior getBaselineResizeBehavior( |
|
121 |
JComponent c) { |
|
122 |
super.getBaselineResizeBehavior(c); |
|
123 |
Border border = c.getBorder(); |
|
124 |
if (border instanceof AbstractBorder) { |
|
125 |
return ((AbstractBorder)border).getBaselineResizeBehavior(c); |
|
126 |
} |
|
127 |
return Component.BaselineResizeBehavior.OTHER; |
|
128 |
} |
|
129 |
} |