author | ant |
Thu, 17 May 2012 21:48:57 +0400 | |
changeset 12661 | 6cf8b7116579 |
parent 12411 | a85a15e74ad5 |
child 20455 | f6f9a0c2796b |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9035
1255eb81cc2f
7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents:
8142
diff
changeset
|
2 |
* Copyright (c) 1997, 2011, 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 |
||
7006
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
27 |
import java.awt.BasicStroke; |
2 | 28 |
import java.awt.Color; |
29 |
import java.awt.Font; |
|
7006
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
30 |
import java.awt.Paint; |
2 | 31 |
import javax.swing.border.*; |
32 |
||
33 |
/** |
|
34 |
* Factory class for vending standard <code>Border</code> objects. Wherever |
|
35 |
* possible, this factory will hand out references to shared |
|
36 |
* <code>Border</code> instances. |
|
37 |
* For further information and examples see |
|
38 |
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/border.html">How |
|
39 |
to Use Borders</a>, |
|
40 |
* a section in <em>The Java Tutorial</em>. |
|
41 |
* |
|
42 |
* @author David Kloba |
|
43 |
*/ |
|
44 |
public class BorderFactory |
|
45 |
{ |
|
46 |
||
47 |
/** Don't let anyone instantiate this class */ |
|
48 |
private BorderFactory() { |
|
49 |
} |
|
50 |
||
51 |
||
52 |
//// LineBorder /////////////////////////////////////////////////////////////// |
|
53 |
/** |
|
54 |
* Creates a line border withe the specified color. |
|
55 |
* |
|
56 |
* @param color a <code>Color</code> to use for the line |
|
57 |
* @return the <code>Border</code> object |
|
58 |
*/ |
|
59 |
public static Border createLineBorder(Color color) { |
|
60 |
return new LineBorder(color, 1); |
|
61 |
} |
|
62 |
||
63 |
/** |
|
64 |
* Creates a line border with the specified color |
|
65 |
* and width. The width applies to all four sides of the |
|
66 |
* border. To specify widths individually for the top, |
|
67 |
* bottom, left, and right, use |
|
68 |
* {@link #createMatteBorder(int,int,int,int,Color)}. |
|
69 |
* |
|
70 |
* @param color a <code>Color</code> to use for the line |
|
71 |
* @param thickness an integer specifying the width in pixels |
|
72 |
* @return the <code>Border</code> object |
|
73 |
*/ |
|
74 |
public static Border createLineBorder(Color color, int thickness) { |
|
75 |
return new LineBorder(color, thickness); |
|
76 |
} |
|
77 |
||
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
78 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
79 |
* Creates a line border with the specified color, thickness, and corner shape. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
80 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
81 |
* @param color the color of the border |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
82 |
* @param thickness the thickness of the border |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
83 |
* @param rounded whether or not border corners should be round |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
84 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
85 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
86 |
* @see LineBorder#LineBorder(Color, int, boolean) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
87 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
88 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
89 |
public static Border createLineBorder(Color color, int thickness, boolean rounded) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
90 |
return new LineBorder(color, thickness, rounded); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
91 |
} |
2 | 92 |
|
93 |
//// BevelBorder ///////////////////////////////////////////////////////////// |
|
94 |
/////////////////////////////////////////////////////////////////////////////// |
|
95 |
static final Border sharedRaisedBevel = new BevelBorder(BevelBorder.RAISED); |
|
96 |
static final Border sharedLoweredBevel = new BevelBorder(BevelBorder.LOWERED); |
|
97 |
||
98 |
/** |
|
99 |
* Creates a border with a raised beveled edge, using |
|
100 |
* brighter shades of the component's current background color |
|
101 |
* for highlighting, and darker shading for shadows. |
|
102 |
* (In a raised border, highlights are on top and shadows |
|
103 |
* are underneath.) |
|
104 |
* |
|
105 |
* @return the <code>Border</code> object |
|
106 |
*/ |
|
107 |
public static Border createRaisedBevelBorder() { |
|
108 |
return createSharedBevel(BevelBorder.RAISED); |
|
109 |
} |
|
110 |
||
111 |
/** |
|
112 |
* Creates a border with a lowered beveled edge, using |
|
113 |
* brighter shades of the component's current background color |
|
114 |
* for highlighting, and darker shading for shadows. |
|
115 |
* (In a lowered border, shadows are on top and highlights |
|
116 |
* are underneath.) |
|
117 |
* |
|
118 |
* @return the <code>Border</code> object |
|
119 |
*/ |
|
120 |
public static Border createLoweredBevelBorder() { |
|
121 |
return createSharedBevel(BevelBorder.LOWERED); |
|
122 |
} |
|
123 |
||
124 |
/** |
|
125 |
* Creates a beveled border of the specified type, using |
|
126 |
* brighter shades of the component's current background color |
|
127 |
* for highlighting, and darker shading for shadows. |
|
128 |
* (In a lowered border, shadows are on top and highlights |
|
129 |
* are underneath.) |
|
130 |
* |
|
131 |
* @param type an integer specifying either |
|
132 |
* <code>BevelBorder.LOWERED</code> or |
|
133 |
* <code>BevelBorder.RAISED</code> |
|
134 |
* @return the <code>Border</code> object |
|
135 |
*/ |
|
136 |
public static Border createBevelBorder(int type) { |
|
137 |
return createSharedBevel(type); |
|
138 |
} |
|
139 |
||
140 |
/** |
|
141 |
* Creates a beveled border of the specified type, using |
|
142 |
* the specified highlighting and shadowing. The outer |
|
143 |
* edge of the highlighted area uses a brighter shade of |
|
144 |
* the highlight color. The inner edge of the shadow area |
|
145 |
* uses a brighter shade of the shadow color. |
|
146 |
* |
|
147 |
* @param type an integer specifying either |
|
148 |
* <code>BevelBorder.LOWERED</code> or |
|
149 |
* <code>BevelBorder.RAISED</code> |
|
150 |
* @param highlight a <code>Color</code> object for highlights |
|
151 |
* @param shadow a <code>Color</code> object for shadows |
|
152 |
* @return the <code>Border</code> object |
|
153 |
*/ |
|
154 |
public static Border createBevelBorder(int type, Color highlight, Color shadow) { |
|
155 |
return new BevelBorder(type, highlight, shadow); |
|
156 |
} |
|
157 |
||
158 |
/** |
|
159 |
* Creates a beveled border of the specified type, using |
|
160 |
* the specified colors for the inner and outer highlight |
|
161 |
* and shadow areas. |
|
162 |
* |
|
163 |
* @param type an integer specifying either |
|
164 |
* <code>BevelBorder.LOWERED</code> or |
|
165 |
* <code>BevelBorder.RAISED</code> |
|
166 |
* @param highlightOuter a <code>Color</code> object for the |
|
167 |
* outer edge of the highlight area |
|
168 |
* @param highlightInner a <code>Color</code> object for the |
|
169 |
* inner edge of the highlight area |
|
170 |
* @param shadowOuter a <code>Color</code> object for the |
|
171 |
* outer edge of the shadow area |
|
172 |
* @param shadowInner a <code>Color</code> object for the |
|
173 |
* inner edge of the shadow area |
|
174 |
* @return the <code>Border</code> object |
|
175 |
*/ |
|
176 |
public static Border createBevelBorder(int type, |
|
177 |
Color highlightOuter, Color highlightInner, |
|
178 |
Color shadowOuter, Color shadowInner) { |
|
179 |
return new BevelBorder(type, highlightOuter, highlightInner, |
|
180 |
shadowOuter, shadowInner); |
|
181 |
} |
|
182 |
||
183 |
static Border createSharedBevel(int type) { |
|
184 |
if(type == BevelBorder.RAISED) { |
|
185 |
return sharedRaisedBevel; |
|
186 |
} else if(type == BevelBorder.LOWERED) { |
|
187 |
return sharedLoweredBevel; |
|
188 |
} |
|
189 |
return null; |
|
190 |
} |
|
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
191 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
192 |
//// SoftBevelBorder /////////////////////////////////////////////////////////// |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
193 |
//////////////////////////////////////////////////////////////////////////////// |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
194 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
195 |
private static Border sharedSoftRaisedBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
196 |
private static Border sharedSoftLoweredBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
197 |
|
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
198 |
/** |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
199 |
* Creates a beveled border with a raised edge and softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
200 |
* using brighter shades of the component's current background color |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
201 |
* for highlighting, and darker shading for shadows. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
202 |
* In a raised border, highlights are on top and shadows are underneath. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
203 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
204 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
205 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
206 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
207 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
208 |
public static Border createRaisedSoftBevelBorder() { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
209 |
if (sharedSoftRaisedBevel == null) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
210 |
sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
211 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
212 |
return sharedSoftRaisedBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
213 |
} |
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 |
* Creates a beveled border with a lowered edge and softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
217 |
* using brighter shades of the component's current background color |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
218 |
* for highlighting, and darker shading for shadows. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
219 |
* In a lowered border, shadows are on top and highlights are underneath. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
220 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
221 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
222 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
223 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
224 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
225 |
public static Border createLoweredSoftBevelBorder() { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
226 |
if (sharedSoftLoweredBevel == null) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
227 |
sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
228 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
229 |
return sharedSoftLoweredBevel; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
230 |
} |
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 |
* Creates a beveled border of the specified type with softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
234 |
* using brighter shades of the component's current background color |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
235 |
* for highlighting, and darker shading for shadows. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
236 |
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
237 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
238 |
* @param type a type of a bevel |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
239 |
* @return the {@code Border} object or {@code null} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
240 |
* if the specified type is not valid |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
241 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
242 |
* @see BevelBorder#BevelBorder(int) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
243 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
244 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
245 |
public static Border createSoftBevelBorder(int type) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
246 |
if (type == BevelBorder.RAISED) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
247 |
return createRaisedSoftBevelBorder(); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
248 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
249 |
if (type == BevelBorder.LOWERED) { |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
250 |
return createLoweredSoftBevelBorder(); |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
251 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
252 |
return null; |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
253 |
} |
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 |
* Creates a beveled border of the specified type with softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
257 |
* using the specified highlighting and shadowing. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
258 |
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
259 |
* The outer edge of the highlight area uses |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
260 |
* a brighter shade of the {@code highlight} color. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
261 |
* The inner edge of the shadow area uses |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
262 |
* a brighter shade of the {@code shadow} color. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
263 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
264 |
* @param type a type of a bevel |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
265 |
* @param highlight a basic color of the highlight area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
266 |
* @param shadow a basic color of the shadow area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
267 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
268 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
269 |
* @see BevelBorder#BevelBorder(int, Color, Color) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
270 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
271 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
272 |
public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) { |
7262
9b7a8d4e0e18
6999033: Methods BorderFactory.createSoftBevelBorder() don't return SoftBevelBorder instances
malenkov
parents:
7006
diff
changeset
|
273 |
return new SoftBevelBorder(type, highlight, shadow); |
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
274 |
} |
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 |
* Creates a beveled border of the specified type with softened corners, |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
278 |
* using the specified colors for the inner and outer edges |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
279 |
* of the highlight and the shadow areas. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
280 |
* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
281 |
* Note: The shadow inner and outer colors are switched |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
282 |
* for a lowered bevel border. |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
283 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
284 |
* @param type a type of a bevel |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
285 |
* @param highlightOuter a color of the outer edge of the highlight area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
286 |
* @param highlightInner a color of the inner edge of the highlight area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
287 |
* @param shadowOuter a color of the outer edge of the shadow area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
288 |
* @param shadowInner a color of the inner edge of the shadow area |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
289 |
* @return the {@code Border} object |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
290 |
* |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
291 |
* @see BevelBorder#BevelBorder(int, Color, Color, Color, Color) |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
292 |
* @since 1.7 |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
293 |
*/ |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
294 |
public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) { |
7262
9b7a8d4e0e18
6999033: Methods BorderFactory.createSoftBevelBorder() don't return SoftBevelBorder instances
malenkov
parents:
7006
diff
changeset
|
295 |
return new SoftBevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner); |
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
296 |
} |
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
297 |
|
2 | 298 |
//// EtchedBorder /////////////////////////////////////////////////////////// |
5765
b9ebe03ab870
5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents:
5506
diff
changeset
|
299 |
|
2 | 300 |
static final Border sharedEtchedBorder = new EtchedBorder(); |
301 |
private static Border sharedRaisedEtchedBorder; |
|
302 |
||
303 |
/** |
|
304 |
* Creates a border with an "etched" look using |
|
305 |
* the component's current background color for |
|
306 |
* highlighting and shading. |
|
307 |
* |
|
308 |
* @return the <code>Border</code> object |
|
309 |
*/ |
|
310 |
public static Border createEtchedBorder() { |
|
311 |
return sharedEtchedBorder; |
|
312 |
} |
|
313 |
||
314 |
/** |
|
315 |
* Creates a border with an "etched" look using |
|
316 |
* the specified highlighting and shading colors. |
|
317 |
* |
|
318 |
* @param highlight a <code>Color</code> object for the border highlights |
|
319 |
* @param shadow a <code>Color</code> object for the border shadows |
|
320 |
* @return the <code>Border</code> object |
|
321 |
*/ |
|
322 |
public static Border createEtchedBorder(Color highlight, Color shadow) { |
|
323 |
return new EtchedBorder(highlight, shadow); |
|
324 |
} |
|
325 |
||
326 |
/** |
|
327 |
* Creates a border with an "etched" look using |
|
328 |
* the component's current background color for |
|
329 |
* highlighting and shading. |
|
330 |
* |
|
331 |
* @param type one of <code>EtchedBorder.RAISED</code>, or |
|
332 |
* <code>EtchedBorder.LOWERED</code> |
|
333 |
* @return the <code>Border</code> object |
|
334 |
* @exception IllegalArgumentException if type is not either |
|
335 |
* <code>EtchedBorder.RAISED</code> or |
|
336 |
* <code>EtchedBorder.LOWERED</code> |
|
337 |
* @since 1.3 |
|
338 |
*/ |
|
339 |
public static Border createEtchedBorder(int type) { |
|
340 |
switch (type) { |
|
341 |
case EtchedBorder.RAISED: |
|
342 |
if (sharedRaisedEtchedBorder == null) { |
|
343 |
sharedRaisedEtchedBorder = new EtchedBorder |
|
344 |
(EtchedBorder.RAISED); |
|
345 |
} |
|
346 |
return sharedRaisedEtchedBorder; |
|
347 |
case EtchedBorder.LOWERED: |
|
348 |
return sharedEtchedBorder; |
|
349 |
default: |
|
350 |
throw new IllegalArgumentException("type must be one of EtchedBorder.RAISED or EtchedBorder.LOWERED"); |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
/** |
|
355 |
* Creates a border with an "etched" look using |
|
356 |
* the specified highlighting and shading colors. |
|
357 |
* |
|
358 |
* @param type one of <code>EtchedBorder.RAISED</code>, or |
|
359 |
* <code>EtchedBorder.LOWERED</code> |
|
360 |
* @param highlight a <code>Color</code> object for the border highlights |
|
361 |
* @param shadow a <code>Color</code> object for the border shadows |
|
362 |
* @return the <code>Border</code> object |
|
363 |
* @since 1.3 |
|
364 |
*/ |
|
365 |
public static Border createEtchedBorder(int type, Color highlight, |
|
366 |
Color shadow) { |
|
367 |
return new EtchedBorder(type, highlight, shadow); |
|
368 |
} |
|
369 |
||
370 |
//// TitledBorder //////////////////////////////////////////////////////////// |
|
371 |
/** |
|
372 |
* Creates a new titled border with the specified title, |
|
373 |
* the default border type (determined by the current look and feel), |
|
12411
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
374 |
* the default text position (determined by the current look and feel), |
2 | 375 |
* the default justification (leading), and the default |
376 |
* font and text color (determined by the current look and feel). |
|
377 |
* |
|
378 |
* @param title a <code>String</code> containing the text of the title |
|
379 |
* @return the <code>TitledBorder</code> object |
|
380 |
*/ |
|
381 |
public static TitledBorder createTitledBorder(String title) { |
|
382 |
return new TitledBorder(title); |
|
383 |
} |
|
384 |
||
385 |
/** |
|
386 |
* Creates a new titled border with an empty title, |
|
387 |
* the specified border object, |
|
12411
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
388 |
* the default text position (determined by the current look and feel), |
2 | 389 |
* the default justification (leading), and the default |
390 |
* font and text color (determined by the current look and feel). |
|
391 |
* |
|
392 |
* @param border the <code>Border</code> object to add the title to; if |
|
393 |
* <code>null</code> the <code>Border</code> is determined |
|
394 |
* by the current look and feel. |
|
395 |
* @return the <code>TitledBorder</code> object |
|
396 |
*/ |
|
397 |
public static TitledBorder createTitledBorder(Border border) { |
|
398 |
return new TitledBorder(border); |
|
399 |
} |
|
400 |
||
401 |
/** |
|
402 |
* Adds a title to an existing border, |
|
12411
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
403 |
* with default positioning (determined by the current look and feel), |
2 | 404 |
* default justification (leading) and the default |
405 |
* font and text color (determined by the current look and feel). |
|
406 |
* |
|
407 |
* @param border the <code>Border</code> object to add the title to |
|
408 |
* @param title a <code>String</code> containing the text of the title |
|
409 |
* @return the <code>TitledBorder</code> object |
|
410 |
*/ |
|
411 |
public static TitledBorder createTitledBorder(Border border, |
|
412 |
String title) { |
|
413 |
return new TitledBorder(border, title); |
|
414 |
} |
|
415 |
||
416 |
/** |
|
417 |
* Adds a title to an existing border, with the specified |
|
418 |
* positioning and using the default |
|
419 |
* font and text color (determined by the current look and feel). |
|
420 |
* |
|
421 |
* @param border the <code>Border</code> object to add the title to |
|
422 |
* @param title a <code>String</code> containing the text of the title |
|
423 |
* @param titleJustification an integer specifying the justification |
|
424 |
* of the title -- one of the following: |
|
425 |
*<ul> |
|
426 |
*<li><code>TitledBorder.LEFT</code> |
|
427 |
*<li><code>TitledBorder.CENTER</code> |
|
428 |
*<li><code>TitledBorder.RIGHT</code> |
|
429 |
*<li><code>TitledBorder.LEADING</code> |
|
430 |
*<li><code>TitledBorder.TRAILING</code> |
|
431 |
*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading) |
|
432 |
*</ul> |
|
433 |
* @param titlePosition an integer specifying the vertical position of |
|
434 |
* the text in relation to the border -- one of the following: |
|
435 |
*<ul> |
|
436 |
*<li><code> TitledBorder.ABOVE_TOP</code> |
|
437 |
*<li><code>TitledBorder.TOP</code> (sitting on the top line) |
|
438 |
*<li><code>TitledBorder.BELOW_TOP</code> |
|
439 |
*<li><code>TitledBorder.ABOVE_BOTTOM</code> |
|
440 |
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line) |
|
441 |
*<li><code>TitledBorder.BELOW_BOTTOM</code> |
|
12411
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
442 |
*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position |
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
443 |
* is determined by the current look and feel) |
2 | 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> |
|
12411
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
481 |
*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position |
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
482 |
* is determined by the current look and feel) |
2 | 483 |
*</ul> |
484 |
* @param titleFont a Font object specifying the title font |
|
485 |
* @return the TitledBorder object |
|
486 |
*/ |
|
487 |
public static TitledBorder createTitledBorder(Border border, |
|
488 |
String title, |
|
489 |
int titleJustification, |
|
490 |
int titlePosition, |
|
491 |
Font titleFont) { |
|
492 |
return new TitledBorder(border, title, titleJustification, |
|
493 |
titlePosition, titleFont); |
|
494 |
} |
|
495 |
||
496 |
/** |
|
497 |
* Adds a title to an existing border, with the specified |
|
498 |
* positioning, font and color. |
|
499 |
* |
|
500 |
* @param border the <code>Border</code> object to add the title to |
|
501 |
* @param title a <code>String</code> containing the text of the title |
|
502 |
* @param titleJustification an integer specifying the justification |
|
503 |
* of the title -- one of the following: |
|
504 |
*<ul> |
|
505 |
*<li><code>TitledBorder.LEFT</code> |
|
506 |
*<li><code>TitledBorder.CENTER</code> |
|
507 |
*<li><code>TitledBorder.RIGHT</code> |
|
508 |
*<li><code>TitledBorder.LEADING</code> |
|
509 |
*<li><code>TitledBorder.TRAILING</code> |
|
510 |
*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading) |
|
511 |
*</ul> |
|
512 |
* @param titlePosition an integer specifying the vertical position of |
|
513 |
* the text in relation to the border -- one of the following: |
|
514 |
*<ul> |
|
515 |
*<li><code> TitledBorder.ABOVE_TOP</code> |
|
516 |
*<li><code>TitledBorder.TOP</code> (sitting on the top line) |
|
517 |
*<li><code>TitledBorder.BELOW_TOP</code> |
|
518 |
*<li><code>TitledBorder.ABOVE_BOTTOM</code> |
|
519 |
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line) |
|
520 |
*<li><code>TitledBorder.BELOW_BOTTOM</code> |
|
12411
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
521 |
*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position |
a85a15e74ad5
7149090: Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
rupashka
parents:
9035
diff
changeset
|
522 |
* is determined by the current look and feel) |
2 | 523 |
*</ul> |
524 |
* @param titleFont a <code>Font</code> object specifying the title font |
|
525 |
* @param titleColor a <code>Color</code> object specifying the title color |
|
526 |
* @return the <code>TitledBorder</code> object |
|
527 |
*/ |
|
528 |
public static TitledBorder createTitledBorder(Border border, |
|
529 |
String title, |
|
530 |
int titleJustification, |
|
531 |
int titlePosition, |
|
532 |
Font titleFont, |
|
533 |
Color titleColor) { |
|
534 |
return new TitledBorder(border, title, titleJustification, |
|
535 |
titlePosition, titleFont, titleColor); |
|
536 |
} |
|
537 |
//// EmptyBorder /////////////////////////////////////////////////////////// |
|
538 |
final static Border emptyBorder = new EmptyBorder(0, 0, 0, 0); |
|
539 |
||
540 |
/** |
|
541 |
* Creates an empty border that takes up no space. (The width |
|
542 |
* of the top, bottom, left, and right sides are all zero.) |
|
543 |
* |
|
544 |
* @return the <code>Border</code> object |
|
545 |
*/ |
|
546 |
public static Border createEmptyBorder() { |
|
547 |
return emptyBorder; |
|
548 |
} |
|
549 |
||
550 |
/** |
|
551 |
* Creates an empty border that takes up space but which does |
|
552 |
* no drawing, specifying the width of the top, left, bottom, and |
|
553 |
* right sides. |
|
554 |
* |
|
555 |
* @param top an integer specifying the width of the top, |
|
556 |
* in pixels |
|
557 |
* @param left an integer specifying the width of the left side, |
|
558 |
* in pixels |
|
559 |
* @param bottom an integer specifying the width of the bottom, |
|
560 |
* in pixels |
|
561 |
* @param right an integer specifying the width of the right side, |
|
562 |
* in pixels |
|
563 |
* @return the <code>Border</code> object |
|
564 |
*/ |
|
565 |
public static Border createEmptyBorder(int top, int left, |
|
566 |
int bottom, int right) { |
|
567 |
return new EmptyBorder(top, left, bottom, right); |
|
568 |
} |
|
569 |
||
570 |
//// CompoundBorder //////////////////////////////////////////////////////// |
|
571 |
/** |
|
572 |
* Creates a compound border with a <code>null</code> inside edge and a |
|
573 |
* <code>null</code> outside edge. |
|
574 |
* |
|
575 |
* @return the <code>CompoundBorder</code> object |
|
576 |
*/ |
|
577 |
public static CompoundBorder createCompoundBorder() { |
|
578 |
return new CompoundBorder(); |
|
579 |
} |
|
580 |
||
581 |
/** |
|
582 |
* Creates a compound border specifying the border objects to use |
|
583 |
* for the outside and inside edges. |
|
584 |
* |
|
585 |
* @param outsideBorder a <code>Border</code> object for the outer |
|
586 |
* edge of the compound border |
|
587 |
* @param insideBorder a <code>Border</code> object for the inner |
|
588 |
* edge of the compound border |
|
589 |
* @return the <code>CompoundBorder</code> object |
|
590 |
*/ |
|
591 |
public static CompoundBorder createCompoundBorder(Border outsideBorder, |
|
592 |
Border insideBorder) { |
|
593 |
return new CompoundBorder(outsideBorder, insideBorder); |
|
594 |
} |
|
595 |
||
596 |
//// MatteBorder //////////////////////////////////////////////////////// |
|
597 |
/** |
|
598 |
* Creates a matte-look border using a solid color. (The difference between |
|
599 |
* this border and a line border is that you can specify the individual |
|
600 |
* border dimensions.) |
|
601 |
* |
|
602 |
* @param top an integer specifying the width of the top, |
|
603 |
* in pixels |
|
604 |
* @param left an integer specifying the width of the left side, |
|
605 |
* in pixels |
|
606 |
* @param bottom an integer specifying the width of the right side, |
|
607 |
* in pixels |
|
608 |
* @param right an integer specifying the width of the bottom, |
|
609 |
* in pixels |
|
610 |
* @param color a <code>Color</code> to use for the border |
|
611 |
* @return the <code>MatteBorder</code> object |
|
612 |
*/ |
|
613 |
public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, |
|
614 |
Color color) { |
|
615 |
return new MatteBorder(top, left, bottom, right, color); |
|
616 |
} |
|
617 |
||
618 |
/** |
|
619 |
* Creates a matte-look border that consists of multiple tiles of a |
|
620 |
* specified icon. Multiple copies of the icon are placed side-by-side |
|
621 |
* to fill up the border area. |
|
622 |
* <p> |
|
623 |
* Note:<br> |
|
624 |
* If the icon doesn't load, the border area is painted gray. |
|
625 |
* |
|
626 |
* @param top an integer specifying the width of the top, |
|
627 |
* in pixels |
|
628 |
* @param left an integer specifying the width of the left side, |
|
629 |
* in pixels |
|
630 |
* @param bottom an integer specifying the width of the right side, |
|
631 |
* in pixels |
|
632 |
* @param right an integer specifying the width of the bottom, |
|
633 |
* in pixels |
|
634 |
* @param tileIcon the <code>Icon</code> object used for the border tiles |
|
635 |
* @return the <code>MatteBorder</code> object |
|
636 |
*/ |
|
637 |
public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, |
|
638 |
Icon tileIcon) { |
|
639 |
return new MatteBorder(top, left, bottom, right, tileIcon); |
|
640 |
} |
|
7006
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
641 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
642 |
//// StrokeBorder ////////////////////////////////////////////////////////////// |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
643 |
//////////////////////////////////////////////////////////////////////////////// |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
644 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
645 |
/** |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
646 |
* Creates a border of the specified {@code stroke}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
647 |
* The component's foreground color will be used to render the border. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
648 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
649 |
* @param stroke the {@link BasicStroke} object used to stroke a shape |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
650 |
* @return the {@code Border} object |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
651 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
652 |
* @throws NullPointerException if the specified {@code stroke} is {@code null} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
653 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
654 |
* @since 1.7 |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
655 |
*/ |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
656 |
public static Border createStrokeBorder(BasicStroke stroke) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
657 |
return new StrokeBorder(stroke); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
658 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
659 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
660 |
/** |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
661 |
* Creates a border of the specified {@code stroke} and {@code paint}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
662 |
* If the specified {@code paint} is {@code null}, |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
663 |
* the component's foreground color will be used to render the border. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
664 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
665 |
* @param stroke the {@link BasicStroke} object used to stroke a shape |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
666 |
* @param paint the {@link Paint} object used to generate a color |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
667 |
* @return the {@code Border} object |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
668 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
669 |
* @throws NullPointerException if the specified {@code stroke} is {@code null} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
670 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
671 |
* @since 1.7 |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
672 |
*/ |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
673 |
public static Border createStrokeBorder(BasicStroke stroke, Paint paint) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
674 |
return new StrokeBorder(stroke, paint); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
675 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
676 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
677 |
//// DashedBorder ////////////////////////////////////////////////////////////// |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
678 |
//////////////////////////////////////////////////////////////////////////////// |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
679 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
680 |
private static Border sharedDashedBorder; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
681 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
682 |
/** |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
683 |
* Creates a dashed border of the specified {@code paint}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
684 |
* If the specified {@code paint} is {@code null}, |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
685 |
* the component's foreground color will be used to render the border. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
686 |
* The width of a dash line is equal to {@code 1}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
687 |
* The relative length of a dash line and |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
688 |
* the relative spacing between dash lines are equal to {@code 1}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
689 |
* A dash line is not rounded. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
690 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
691 |
* @param paint the {@link Paint} object used to generate a color |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
692 |
* @return the {@code Border} object |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
693 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
694 |
* @since 1.7 |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
695 |
*/ |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
696 |
public static Border createDashedBorder(Paint paint) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
697 |
return createDashedBorder(paint, 1.0f, 1.0f, 1.0f, false); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
698 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
699 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
700 |
/** |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
701 |
* Creates a dashed border of the specified {@code paint}, |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
702 |
* relative {@code length}, and relative {@code spacing}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
703 |
* If the specified {@code paint} is {@code null}, |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
704 |
* the component's foreground color will be used to render the border. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
705 |
* The width of a dash line is equal to {@code 1}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
706 |
* A dash line is not rounded. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
707 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
708 |
* @param paint the {@link Paint} object used to generate a color |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
709 |
* @param length the relative length of a dash line |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
710 |
* @param spacing the relative spacing between dash lines |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
711 |
* @return the {@code Border} object |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
712 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
713 |
* @throws IllegalArgumentException if the specified {@code length} is less than {@code 1}, or |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
714 |
* if the specified {@code spacing} is less than {@code 0} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
715 |
* @since 1.7 |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
716 |
*/ |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
717 |
public static Border createDashedBorder(Paint paint, float length, float spacing) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
718 |
return createDashedBorder(paint, 1.0f, length, spacing, false); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
719 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
720 |
|
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
721 |
/** |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
722 |
* Creates a dashed border of the specified {@code paint}, {@code thickness}, |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
723 |
* line shape, relative {@code length}, and relative {@code spacing}. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
724 |
* If the specified {@code paint} is {@code null}, |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
725 |
* the component's foreground color will be used to render the border. |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
726 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
727 |
* @param paint the {@link Paint} object used to generate a color |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
728 |
* @param thickness the width of a dash line |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
729 |
* @param length the relative length of a dash line |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
730 |
* @param spacing the relative spacing between dash lines |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
731 |
* @param rounded whether or not line ends should be round |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
732 |
* @return the {@code Border} object |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
733 |
* |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
734 |
* @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
735 |
* if the specified {@code length} is less than {@code 1}, or |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
736 |
* if the specified {@code spacing} is less than {@code 0} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
737 |
* @since 1.7 |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
738 |
*/ |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
739 |
public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
740 |
boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
741 |
if (shared && (sharedDashedBorder != null)) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
742 |
return sharedDashedBorder; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
743 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
744 |
if (thickness < 1.0f) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
745 |
throw new IllegalArgumentException("thickness is less than 1"); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
746 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
747 |
if (length < 1.0f) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
748 |
throw new IllegalArgumentException("length is less than 1"); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
749 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
750 |
if (spacing < 0.0f) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
751 |
throw new IllegalArgumentException("spacing is less than 0"); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
752 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
753 |
int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
754 |
int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
755 |
float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) }; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
756 |
Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint); |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
757 |
if (shared) { |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
758 |
sharedDashedBorder = border; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
759 |
} |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
760 |
return border; |
05505fff1342
4358979: javax.swing.border should have a DashedBorder
malenkov
parents:
5765
diff
changeset
|
761 |
} |
2 | 762 |
} |