author | alexp |
Fri, 02 Jul 2010 19:34:34 +0400 | |
changeset 5956 | e30f106a4b8b |
parent 5765 | b9ebe03ab870 |
child 7006 | 05505fff1342 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1997, 2010, 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 |
package javax.swing; |
|
26 |
||
27 |
import java.awt.Color; |
|
28 |
import java.awt.Font; |
|
29 |
import javax.swing.border.*; |
|
30 |
||
31 |
/** |
|
32 |
* Factory class for vending standard <code>Border</code> objects. Wherever |
|
33 |
* possible, this factory will hand out references to shared |
|
34 |
* <code>Border</code> instances. |
|
35 |
* For further information and examples see |
|
36 |
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/border.html">How |
|
37 |
to Use Borders</a>, |
|
38 |
* a section in <em>The Java Tutorial</em>. |
|
39 |
* |
|
40 |
* @author David Kloba |
|
41 |
*/ |
|
42 |
public class BorderFactory |
|
43 |
{ |
|
44 |
||
45 |
/** Don't let anyone instantiate this class */ |
|
46 |
private BorderFactory() { |
|
47 |
} |
|
48 |
||
49 |
||
50 |
//// LineBorder /////////////////////////////////////////////////////////////// |
|
51 |
/** |
|
52 |
* Creates a line border withe the specified color. |
|
53 |
* |
|
54 |
* @param color a <code>Color</code> to use for the line |
|
55 |
* @return the <code>Border</code> object |
|
56 |
*/ |
|
57 |
public static Border createLineBorder(Color color) { |
|
58 |
return new LineBorder(color, 1); |
|
59 |
} |
|
60 |
||
61 |
/** |
|
62 |
* Creates a line border with the specified color |
|
63 |
* and width. The width applies to all four sides of the |
|
64 |
* border. To specify widths individually for the top, |
|
65 |
* bottom, left, and right, use |
|
66 |
* {@link #createMatteBorder(int,int,int,int,Color)}. |
|
67 |
* |
|
68 |
* @param color a <code>Color</code> to use for the line |
|
69 |
* @param thickness an integer specifying the width in pixels |
|
70 |
* @return the <code>Border</code> object |
|
71 |
*/ |
|
72 |
public static Border createLineBorder(Color color, int thickness) { |
|
73 |
return new LineBorder(color, thickness); |
|
74 |
} |
|
75 |
||
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
76 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
77 |
* Creates a line border with the specified color, thickness, and corner shape. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
78 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
79 |
* @param color the color of the border |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
80 |
* @param thickness the thickness of the border |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
81 |
* @param rounded whether or not border corners should be round |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
82 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
83 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
84 |
* @see LineBorder#LineBorder(Color, int, boolean) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
85 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
86 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
87 |
public static Border createLineBorder(Color color, int thickness, boolean rounded) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
88 |
return new LineBorder(color, thickness, rounded); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
89 |
} |
2 | 90 |
|
91 |
//// BevelBorder ///////////////////////////////////////////////////////////// |
|
92 |
/////////////////////////////////////////////////////////////////////////////// |
|
93 |
static final Border sharedRaisedBevel = new BevelBorder(BevelBorder.RAISED); |
|
94 |
static final Border sharedLoweredBevel = new BevelBorder(BevelBorder.LOWERED); |
|
95 |
||
96 |
/** |
|
97 |
* Creates a border with a raised beveled edge, using |
|
98 |
* brighter shades of the component's current background color |
|
99 |
* for highlighting, and darker shading for shadows. |
|
100 |
* (In a raised border, highlights are on top and shadows |
|
101 |
* are underneath.) |
|
102 |
* |
|
103 |
* @return the <code>Border</code> object |
|
104 |
*/ |
|
105 |
public static Border createRaisedBevelBorder() { |
|
106 |
return createSharedBevel(BevelBorder.RAISED); |
|
107 |
} |
|
108 |
||
109 |
/** |
|
110 |
* Creates a border with a lowered beveled edge, using |
|
111 |
* brighter shades of the component's current background color |
|
112 |
* for highlighting, and darker shading for shadows. |
|
113 |
* (In a lowered border, shadows are on top and highlights |
|
114 |
* are underneath.) |
|
115 |
* |
|
116 |
* @return the <code>Border</code> object |
|
117 |
*/ |
|
118 |
public static Border createLoweredBevelBorder() { |
|
119 |
return createSharedBevel(BevelBorder.LOWERED); |
|
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* Creates a beveled border of the specified type, using |
|
124 |
* brighter shades of the component's current background color |
|
125 |
* for highlighting, and darker shading for shadows. |
|
126 |
* (In a lowered border, shadows are on top and highlights |
|
127 |
* are underneath.) |
|
128 |
* |
|
129 |
* @param type an integer specifying either |
|
130 |
* <code>BevelBorder.LOWERED</code> or |
|
131 |
* <code>BevelBorder.RAISED</code> |
|
132 |
* @return the <code>Border</code> object |
|
133 |
*/ |
|
134 |
public static Border createBevelBorder(int type) { |
|
135 |
return createSharedBevel(type); |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* Creates a beveled border of the specified type, using |
|
140 |
* the specified highlighting and shadowing. The outer |
|
141 |
* edge of the highlighted area uses a brighter shade of |
|
142 |
* the highlight color. The inner edge of the shadow area |
|
143 |
* uses a brighter shade of the shadow color. |
|
144 |
* |
|
145 |
* @param type an integer specifying either |
|
146 |
* <code>BevelBorder.LOWERED</code> or |
|
147 |
* <code>BevelBorder.RAISED</code> |
|
148 |
* @param highlight a <code>Color</code> object for highlights |
|
149 |
* @param shadow a <code>Color</code> object for shadows |
|
150 |
* @return the <code>Border</code> object |
|
151 |
*/ |
|
152 |
public static Border createBevelBorder(int type, Color highlight, Color shadow) { |
|
153 |
return new BevelBorder(type, highlight, shadow); |
|
154 |
} |
|
155 |
||
156 |
/** |
|
157 |
* Creates a beveled border of the specified type, using |
|
158 |
* the specified colors for the inner and outer highlight |
|
159 |
* and shadow areas. |
|
160 |
* <p> |
|
161 |
* Note: The shadow inner and outer colors are |
|
162 |
* switched for a lowered bevel border. |
|
163 |
* |
|
164 |
* @param type an integer specifying either |
|
165 |
* <code>BevelBorder.LOWERED</code> or |
|
166 |
* <code>BevelBorder.RAISED</code> |
|
167 |
* @param highlightOuter a <code>Color</code> object for the |
|
168 |
* outer edge of the highlight area |
|
169 |
* @param highlightInner a <code>Color</code> object for the |
|
170 |
* inner edge of the highlight area |
|
171 |
* @param shadowOuter a <code>Color</code> object for the |
|
172 |
* outer edge of the shadow area |
|
173 |
* @param shadowInner a <code>Color</code> object for the |
|
174 |
* inner edge of the shadow area |
|
175 |
* @return the <code>Border</code> object |
|
176 |
*/ |
|
177 |
public static Border createBevelBorder(int type, |
|
178 |
Color highlightOuter, Color highlightInner, |
|
179 |
Color shadowOuter, Color shadowInner) { |
|
180 |
return new BevelBorder(type, highlightOuter, highlightInner, |
|
181 |
shadowOuter, shadowInner); |
|
182 |
} |
|
183 |
||
184 |
static Border createSharedBevel(int type) { |
|
185 |
if(type == BevelBorder.RAISED) { |
|
186 |
return sharedRaisedBevel; |
|
187 |
} else if(type == BevelBorder.LOWERED) { |
|
188 |
return sharedLoweredBevel; |
|
189 |
} |
|
190 |
return null; |
|
191 |
} |
|
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
192 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
193 |
//// SoftBevelBorder /////////////////////////////////////////////////////////// |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
194 |
//////////////////////////////////////////////////////////////////////////////// |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
195 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
196 |
private static Border sharedSoftRaisedBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
197 |
private static Border sharedSoftLoweredBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
198 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
199 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
200 |
* Creates a beveled border with a raised edge and softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
201 |
* using brighter shades of the component's current background color |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
202 |
* for highlighting, and darker shading for shadows. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
203 |
* In a raised border, highlights are on top and shadows are underneath. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
204 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
205 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
206 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
207 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
208 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
209 |
public static Border createRaisedSoftBevelBorder() { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
210 |
if (sharedSoftRaisedBevel == null) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
211 |
sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
212 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
213 |
return sharedSoftRaisedBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
214 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
215 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
216 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
217 |
* Creates a beveled border with a lowered edge and softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
218 |
* using brighter shades of the component's current background color |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
219 |
* for highlighting, and darker shading for shadows. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
220 |
* In a lowered border, shadows are on top and highlights are underneath. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
221 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
222 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
223 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
224 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
225 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
226 |
public static Border createLoweredSoftBevelBorder() { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
227 |
if (sharedSoftLoweredBevel == null) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
228 |
sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
229 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
230 |
return sharedSoftLoweredBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
231 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
232 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
233 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
234 |
* Creates a beveled border of the specified type with softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
235 |
* using brighter shades of the component's current background color |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
236 |
* for highlighting, and darker shading for shadows. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
237 |
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
238 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
239 |
* @param type a type of a bevel |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
240 |
* @return the {@code Border} object or {@code null} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
241 |
* if the specified type is not valid |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
242 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
243 |
* @see BevelBorder#BevelBorder(int) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
244 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
245 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
246 |
public static Border createSoftBevelBorder(int type) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
247 |
if (type == BevelBorder.RAISED) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
248 |
return createRaisedSoftBevelBorder(); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
249 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
250 |
if (type == BevelBorder.LOWERED) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
251 |
return createLoweredSoftBevelBorder(); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
252 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
253 |
return null; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
254 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
255 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
256 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
257 |
* Creates a beveled border of the specified type with softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
258 |
* using the specified highlighting and shadowing. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
259 |
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
260 |
* The outer edge of the highlight area uses |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
261 |
* a brighter shade of the {@code highlight} color. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
262 |
* The inner edge of the shadow area uses |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
263 |
* a brighter shade of the {@code shadow} color. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
264 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
265 |
* @param type a type of a bevel |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
266 |
* @param highlight a basic color of the highlight area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
267 |
* @param shadow a basic color of the shadow area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
268 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
269 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
270 |
* @see BevelBorder#BevelBorder(int, Color, Color) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
271 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
272 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
273 |
public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
274 |
return new BevelBorder(type, highlight, shadow); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
275 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
276 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
277 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
278 |
* Creates a beveled border of the specified type with softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
279 |
* using the specified colors for the inner and outer edges |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
280 |
* of the highlight and the shadow areas. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
281 |
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
282 |
* Note: The shadow inner and outer colors are switched |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
283 |
* for a lowered bevel border. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
284 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
285 |
* @param type a type of a bevel |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
286 |
* @param highlightOuter a color of the outer edge of the highlight area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
287 |
* @param highlightInner a color of the inner edge of the highlight area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
288 |
* @param shadowOuter a color of the outer edge of the shadow area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
289 |
* @param shadowInner a color of the inner edge of the shadow area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
290 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
291 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
292 |
* @see BevelBorder#BevelBorder(int, Color, Color, Color, Color) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
293 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
294 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
295 |
public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
296 |
return new BevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
297 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
298 |
|
2 | 299 |
//// EtchedBorder /////////////////////////////////////////////////////////// |
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
300 |
|
2 | 301 |
static final Border sharedEtchedBorder = new EtchedBorder(); |
302 |
private static Border sharedRaisedEtchedBorder; |
|
303 |
||
304 |
/** |
|
305 |
* Creates a border with an "etched" look using |
|
306 |
* the component's current background color for |
|
307 |
* highlighting and shading. |
|
308 |
* |
|
309 |
* @return the <code>Border</code> object |
|
310 |
*/ |
|
311 |
public static Border createEtchedBorder() { |
|
312 |
return sharedEtchedBorder; |
|
313 |
} |
|
314 |
||
315 |
/** |
|
316 |
* Creates a border with an "etched" look using |
|
317 |
* the specified highlighting and shading colors. |
|
318 |
* |
|
319 |
* @param highlight a <code>Color</code> object for the border highlights |
|
320 |
* @param shadow a <code>Color</code> object for the border shadows |
|
321 |
* @return the <code>Border</code> object |
|
322 |
*/ |
|
323 |
public static Border createEtchedBorder(Color highlight, Color shadow) { |
|
324 |
return new EtchedBorder(highlight, shadow); |
|
325 |
} |
|
326 |
||
327 |
/** |
|
328 |
* Creates a border with an "etched" look using |
|
329 |
* the component's current background color for |
|
330 |
* highlighting and shading. |
|
331 |
* |
|
332 |
* @param type one of <code>EtchedBorder.RAISED</code>, or |
|
333 |
* <code>EtchedBorder.LOWERED</code> |
|
334 |
* @return the <code>Border</code> object |
|
335 |
* @exception IllegalArgumentException if type is not either |
|
336 |
* <code>EtchedBorder.RAISED</code> or |
|
337 |
* <code>EtchedBorder.LOWERED</code> |
|
338 |
* @since 1.3 |
|
339 |
*/ |
|
340 |
public static Border createEtchedBorder(int type) { |
|
341 |
switch (type) { |
|
342 |
case EtchedBorder.RAISED: |
|
343 |
if (sharedRaisedEtchedBorder == null) { |
|
344 |
sharedRaisedEtchedBorder = new EtchedBorder |
|
345 |
(EtchedBorder.RAISED); |
|
346 |
} |
|
347 |
return sharedRaisedEtchedBorder; |
|
348 |
case EtchedBorder.LOWERED: |
|
349 |
return sharedEtchedBorder; |
|
350 |
default: |
|
351 |
throw new IllegalArgumentException("type must be one of EtchedBorder.RAISED or EtchedBorder.LOWERED"); |
|
352 |
} |
|
353 |
} |
|
354 |
||
355 |
/** |
|
356 |
* Creates a border with an "etched" look using |
|
357 |
* the specified highlighting and shading colors. |
|
358 |
* |
|
359 |
* @param type one of <code>EtchedBorder.RAISED</code>, or |
|
360 |
* <code>EtchedBorder.LOWERED</code> |
|
361 |
* @param highlight a <code>Color</code> object for the border highlights |
|
362 |
* @param shadow a <code>Color</code> object for the border shadows |
|
363 |
* @return the <code>Border</code> object |
|
364 |
* @since 1.3 |
|
365 |
*/ |
|
366 |
public static Border createEtchedBorder(int type, Color highlight, |
|
367 |
Color shadow) { |
|
368 |
return new EtchedBorder(type, highlight, shadow); |
|
369 |
} |
|
370 |
||
371 |
//// TitledBorder //////////////////////////////////////////////////////////// |
|
372 |
/** |
|
373 |
* Creates a new titled border with the specified title, |
|
374 |
* the default border type (determined by the current look and feel), |
|
375 |
* the default text position (sitting on the top line), |
|
376 |
* the default justification (leading), and the default |
|
377 |
* font and text color (determined by the current look and feel). |
|
378 |
* |
|
379 |
* @param title a <code>String</code> containing the text of the title |
|
380 |
* @return the <code>TitledBorder</code> object |
|
381 |
*/ |
|
382 |
public static TitledBorder createTitledBorder(String title) { |
|
383 |
return new TitledBorder(title); |
|
384 |
} |
|
385 |
||
386 |
/** |
|
387 |
* Creates a new titled border with an empty title, |
|
388 |
* the specified border object, |
|
389 |
* the default text position (sitting on the top line), |
|
390 |
* the default justification (leading), and the default |
|
391 |
* font and text color (determined by the current look and feel). |
|
392 |
* |
|
393 |
* @param border the <code>Border</code> object to add the title to; if |
|
394 |
* <code>null</code> the <code>Border</code> is determined |
|
395 |
* by the current look and feel. |
|
396 |
* @return the <code>TitledBorder</code> object |
|
397 |
*/ |
|
398 |
public static TitledBorder createTitledBorder(Border border) { |
|
399 |
return new TitledBorder(border); |
|
400 |
} |
|
401 |
||
402 |
/** |
|
403 |
* Adds a title to an existing border, |
|
404 |
* with default positioning (sitting on the top line), |
|
405 |
* default justification (leading) and the default |
|
406 |
* font and text color (determined by the current look and feel). |
|
407 |
* |
|
408 |
* @param border the <code>Border</code> object to add the title to |
|
409 |
* @param title a <code>String</code> containing the text of the title |
|
410 |
* @return the <code>TitledBorder</code> object |
|
411 |
*/ |
|
412 |
public static TitledBorder createTitledBorder(Border border, |
|
413 |
String title) { |
|
414 |
return new TitledBorder(border, title); |
|
415 |
} |
|
416 |
||
417 |
/** |
|
418 |
* Adds a title to an existing border, with the specified |
|
419 |
* positioning and using the default |
|
420 |
* font and text color (determined by the current look and feel). |
|
421 |
* |
|
422 |
* @param border the <code>Border</code> object to add the title to |
|
423 |
* @param title a <code>String</code> containing the text of the title |
|
424 |
* @param titleJustification an integer specifying the justification |
|
425 |
* of the title -- one of the following: |
|
426 |
*<ul> |
|
427 |
*<li><code>TitledBorder.LEFT</code> |
|
428 |
*<li><code>TitledBorder.CENTER</code> |
|
429 |
*<li><code>TitledBorder.RIGHT</code> |
|
430 |
*<li><code>TitledBorder.LEADING</code> |
|
431 |
*<li><code>TitledBorder.TRAILING</code> |
|
432 |
*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading) |
|
433 |
*</ul> |
|
434 |
* @param titlePosition an integer specifying the vertical position of |
|
435 |
* the text in relation to the border -- one of the following: |
|
436 |
*<ul> |
|
437 |
*<li><code> TitledBorder.ABOVE_TOP</code> |
|
438 |
*<li><code>TitledBorder.TOP</code> (sitting on the top line) |
|
439 |
*<li><code>TitledBorder.BELOW_TOP</code> |
|
440 |
*<li><code>TitledBorder.ABOVE_BOTTOM</code> |
|
441 |
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line) |
|
442 |
*<li><code>TitledBorder.BELOW_BOTTOM</code> |
|
443 |
*<li><code>TitledBorder.DEFAULT_POSITION</code> (top) |
|
444 |
*</ul> |
|
445 |
* @return the <code>TitledBorder</code> object |
|
446 |
*/ |
|
447 |
public static TitledBorder createTitledBorder(Border border, |
|
448 |
String title, |
|
449 |
int titleJustification, |
|
450 |
int titlePosition) { |
|
451 |
return new TitledBorder(border, title, titleJustification, |
|
452 |
titlePosition); |
|
453 |
} |
|
454 |
||
455 |
/** |
|
456 |
* Adds a title to an existing border, with the specified |
|
457 |
* positioning and font, and using the default text color |
|
458 |
* (determined by the current look and feel). |
|
459 |
* |
|
460 |
* @param border the <code>Border</code> object to add the title to |
|
461 |
* @param title a <code>String</code> containing the text of the title |
|
462 |
* @param titleJustification an integer specifying the justification |
|
463 |
* of the title -- one of the following: |
|
464 |
*<ul> |
|
465 |
*<li><code>TitledBorder.LEFT</code> |
|
466 |
*<li><code>TitledBorder.CENTER</code> |
|
467 |
*<li><code>TitledBorder.RIGHT</code> |
|
468 |
*<li><code>TitledBorder.LEADING</code> |
|
469 |
*<li><code>TitledBorder.TRAILING</code> |
|
470 |
*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading) |
|
471 |
*</ul> |
|
472 |
* @param titlePosition an integer specifying the vertical position of |
|
473 |
* the text in relation to the border -- one of the following: |
|
474 |
*<ul> |
|
475 |
*<li><code> TitledBorder.ABOVE_TOP</code> |
|
476 |
*<li><code>TitledBorder.TOP</code> (sitting on the top line) |
|
477 |
*<li><code>TitledBorder.BELOW_TOP</code> |
|
478 |
*<li><code>TitledBorder.ABOVE_BOTTOM</code> |
|
479 |
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line) |
|
480 |
*<li><code>TitledBorder.BELOW_BOTTOM</code> |
|
481 |
*<li><code>TitledBorder.DEFAULT_POSITION</code> (top) |
|
482 |
*</ul> |
|
483 |
* @param titleFont a Font object specifying the title font |
|
484 |
* @return the TitledBorder object |
|
485 |
*/ |
|
486 |
public static TitledBorder createTitledBorder(Border border, |
|
487 |
String title, |
|
488 |
int titleJustification, |
|
489 |
int titlePosition, |
|
490 |
Font titleFont) { |
|
491 |
return new TitledBorder(border, title, titleJustification, |
|
492 |
titlePosition, titleFont); |
|
493 |
} |
|
494 |
||
495 |
/** |
|
496 |
* Adds a title to an existing border, with the specified |
|
497 |
* positioning, font and color. |
|
498 |
* |
|
499 |
* @param border the <code>Border</code> object to add the title to |
|
500 |
* @param title a <code>String</code> containing the text of the title |
|
501 |
* @param titleJustification an integer specifying the justification |
|
502 |
* of the title -- one of the following: |
|
503 |
*<ul> |
|
504 |
*<li><code>TitledBorder.LEFT</code> |
|
505 |
*<li><code>TitledBorder.CENTER</code> |
|
506 |
*<li><code>TitledBorder.RIGHT</code> |
|
507 |
*<li><code>TitledBorder.LEADING</code> |
|
508 |
*<li><code>TitledBorder.TRAILING</code> |
|
509 |
*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading) |
|
510 |
*</ul> |
|
511 |
* @param titlePosition an integer specifying the vertical position of |
|
512 |
* the text in relation to the border -- one of the following: |
|
513 |
*<ul> |
|
514 |
*<li><code> TitledBorder.ABOVE_TOP</code> |
|
515 |
*<li><code>TitledBorder.TOP</code> (sitting on the top line) |
|
516 |
*<li><code>TitledBorder.BELOW_TOP</code> |
|
517 |
*<li><code>TitledBorder.ABOVE_BOTTOM</code> |
|
518 |
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line) |
|
519 |
*<li><code>TitledBorder.BELOW_BOTTOM</code> |
|
520 |
*<li><code>TitledBorder.DEFAULT_POSITION</code> (top) |
|
521 |
*</ul> |
|
522 |
* @param titleFont a <code>Font</code> object specifying the title font |
|
523 |
* @param titleColor a <code>Color</code> object specifying the title color |
|
524 |
* @return the <code>TitledBorder</code> object |
|
525 |
*/ |
|
526 |
public static TitledBorder createTitledBorder(Border border, |
|
527 |
String title, |
|
528 |
int titleJustification, |
|
529 |
int titlePosition, |
|
530 |
Font titleFont, |
|
531 |
Color titleColor) { |
|
532 |
return new TitledBorder(border, title, titleJustification, |
|
533 |
titlePosition, titleFont, titleColor); |
|
534 |
} |
|
535 |
//// EmptyBorder /////////////////////////////////////////////////////////// |
|
536 |
final static Border emptyBorder = new EmptyBorder(0, 0, 0, 0); |
|
537 |
||
538 |
/** |
|
539 |
* Creates an empty border that takes up no space. (The width |
|
540 |
* of the top, bottom, left, and right sides are all zero.) |
|
541 |
* |
|
542 |
* @return the <code>Border</code> object |
|
543 |
*/ |
|
544 |
public static Border createEmptyBorder() { |
|
545 |
return emptyBorder; |
|
546 |
} |
|
547 |
||
548 |
/** |
|
549 |
* Creates an empty border that takes up space but which does |
|
550 |
* no drawing, specifying the width of the top, left, bottom, and |
|
551 |
* right sides. |
|
552 |
* |
|
553 |
* @param top an integer specifying the width of the top, |
|
554 |
* in pixels |
|
555 |
* @param left an integer specifying the width of the left side, |
|
556 |
* in pixels |
|
557 |
* @param bottom an integer specifying the width of the bottom, |
|
558 |
* in pixels |
|
559 |
* @param right an integer specifying the width of the right side, |
|
560 |
* in pixels |
|
561 |
* @return the <code>Border</code> object |
|
562 |
*/ |
|
563 |
public static Border createEmptyBorder(int top, int left, |
|
564 |
int bottom, int right) { |
|
565 |
return new EmptyBorder(top, left, bottom, right); |
|
566 |
} |
|
567 |
||
568 |
//// CompoundBorder //////////////////////////////////////////////////////// |
|
569 |
/** |
|
570 |
* Creates a compound border with a <code>null</code> inside edge and a |
|
571 |
* <code>null</code> outside edge. |
|
572 |
* |
|
573 |
* @return the <code>CompoundBorder</code> object |
|
574 |
*/ |
|
575 |
public static CompoundBorder createCompoundBorder() { |
|
576 |
return new CompoundBorder(); |
|
577 |
} |
|
578 |
||
579 |
/** |
|
580 |
* Creates a compound border specifying the border objects to use |
|
581 |
* for the outside and inside edges. |
|
582 |
* |
|
583 |
* @param outsideBorder a <code>Border</code> object for the outer |
|
584 |
* edge of the compound border |
|
585 |
* @param insideBorder a <code>Border</code> object for the inner |
|
586 |
* edge of the compound border |
|
587 |
* @return the <code>CompoundBorder</code> object |
|
588 |
*/ |
|
589 |
public static CompoundBorder createCompoundBorder(Border outsideBorder, |
|
590 |
Border insideBorder) { |
|
591 |
return new CompoundBorder(outsideBorder, insideBorder); |
|
592 |
} |
|
593 |
||
594 |
//// MatteBorder //////////////////////////////////////////////////////// |
|
595 |
/** |
|
596 |
* Creates a matte-look border using a solid color. (The difference between |
|
597 |
* this border and a line border is that you can specify the individual |
|
598 |
* border dimensions.) |
|
599 |
* |
|
600 |
* @param top an integer specifying the width of the top, |
|
601 |
* in pixels |
|
602 |
* @param left an integer specifying the width of the left side, |
|
603 |
* in pixels |
|
604 |
* @param bottom an integer specifying the width of the right side, |
|
605 |
* in pixels |
|
606 |
* @param right an integer specifying the width of the bottom, |
|
607 |
* in pixels |
|
608 |
* @param color a <code>Color</code> to use for the border |
|
609 |
* @return the <code>MatteBorder</code> object |
|
610 |
*/ |
|
611 |
public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, |
|
612 |
Color color) { |
|
613 |
return new MatteBorder(top, left, bottom, right, color); |
|
614 |
} |
|
615 |
||
616 |
/** |
|
617 |
* Creates a matte-look border that consists of multiple tiles of a |
|
618 |
* specified icon. Multiple copies of the icon are placed side-by-side |
|
619 |
* to fill up the border area. |
|
620 |
* <p> |
|
621 |
* Note:<br> |
|
622 |
* If the icon doesn't load, the border area is painted gray. |
|
623 |
* |
|
624 |
* @param top an integer specifying the width of the top, |
|
625 |
* in pixels |
|
626 |
* @param left an integer specifying the width of the left side, |
|
627 |
* in pixels |
|
628 |
* @param bottom an integer specifying the width of the right side, |
|
629 |
* in pixels |
|
630 |
* @param right an integer specifying the width of the bottom, |
|
631 |
* in pixels |
|
632 |
* @param tileIcon the <code>Icon</code> object used for the border tiles |
|
633 |
* @return the <code>MatteBorder</code> object |
|
634 |
*/ |
|
635 |
public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, |
|
636 |
Icon tileIcon) { |
|
637 |
return new MatteBorder(top, left, bottom, right, tileIcon); |
|
638 |
} |
|
639 |
} |