Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / javax / swing / BorderFactory.java
blobca78deb129003ecfc200a2e8683f43dd50d13eaa
1 /* BorderFactory.java --
2 Copyright (C) 2002, 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing;
41 import java.awt.Color;
42 import java.awt.Font;
44 import javax.swing.border.BevelBorder;
45 import javax.swing.border.Border;
46 import javax.swing.border.CompoundBorder;
47 import javax.swing.border.EmptyBorder;
48 import javax.swing.border.EtchedBorder;
49 import javax.swing.border.LineBorder;
50 import javax.swing.border.MatteBorder;
51 import javax.swing.border.TitledBorder;
53 /**
54 * A factory for commonly used borders.
56 * @author original author unknown
58 public class BorderFactory
60 private BorderFactory()
62 // Do nothing.
65 /**
66 * Creates a line border withe the specified color.
68 * @param color A color to use for the line.
70 * @return The Border object
72 public static Border createLineBorder(Color color)
74 return createLineBorder(color, 1);
77 /**
78 * Creates a line border withe the specified color and width. The width
79 * applies to all 4 sides of the border. To specify widths individually for
80 * the top, bottom, left, and right, use
81 * createMatteBorder(int,int,int,int,Color).
83 * @param color A color to use for the line.
84 * @param thickness An int specifying the width in pixels.
86 * @return The Border object
88 public static Border createLineBorder(Color color, int thickness)
90 return new LineBorder(color, thickness);
93 /**
94 * Created a border with a raised beveled edge, using brighter shades of
95 * the component's current background color for highlighting, and darker
96 * shading for shadows. (In a raised border, highlights are on top and
97 * shadows are underneath.)
99 * @return The Border object
101 public static Border createRaisedBevelBorder()
103 return new BevelBorder(BevelBorder.RAISED);
107 * Created a border with a lowered beveled edge, using brighter shades of
108 * the component's current background color for highlighting, and darker
109 * shading for shadows. (In a lowered border, shadows are on top and
110 * highlights are underneath.)
112 * @return The Border object
114 public static Border createLoweredBevelBorder()
116 return new BevelBorder(BevelBorder.LOWERED);
120 * Create a beveled border of the specified type, using brighter shades of
121 * the component's current background color for highlighting, and darker
122 * shading for shadows. (In a lowered border, shadows are on top and
123 * highlights are underneath.).
125 * @param type An int specifying either BevelBorder.LOWERED or
126 * BevelBorder.RAISED
128 * @return The Border object
130 public static Border createBevelBorder(int type)
132 return new BevelBorder(type);
136 * Create a beveled border of the specified type, using the specified
137 * highlighting and shadowing. The outer edge of the highlighted area uses
138 * a brighter shade of the highlight color. The inner edge of the shadow
139 * area uses a brighter shade of the shadaw color.
141 * @param type An int specifying either BevelBorder.LOWERED or
142 * BevelBorder.RAISED
143 * @param highlight A Color object for highlights
144 * @param shadow A Color object for shadows
146 * @return The Border object
148 public static Border createBevelBorder(int type, Color highlight, Color shadow)
150 return new BevelBorder(type, highlight, shadow);
154 * Create a beveled border of the specified type, using the specified colors
155 * for the inner and outer highlight and shadow areas.
157 * @param type An int specifying either BevelBorder.LOWERED or
158 * BevelBorder.RAISED
159 * @param highlightOuter A Color object for the outer edge of the
160 * highlight area
161 * @param highlightInner A Color object for the inner edge of the
162 * highlight area
163 * @param shadowOuter A Color object for the outer edge of the shadow area
164 * @param shadowInner A Color object for the inner edge of the shadow area
166 * @return The Border object
168 public static Border createBevelBorder(int type, Color highlightOuter,
169 Color highlightInner,
170 Color shadowOuter, Color shadowInner)
172 return new BevelBorder(type, highlightOuter, highlightInner, shadowOuter,
173 shadowInner);
177 * Create a border with an "etched" look using the component's current
178 * background color for highlighting and shading.
180 * @return The Border object
182 public static Border createEtchedBorder()
184 return new EtchedBorder();
188 * Create a border with an "etched" look using the component's current
189 * background color for highlighting and shading.
191 * @return The Border object
193 public static Border createEtchedBorder(int etchType)
195 return new EtchedBorder(etchType);
199 * Create a border with an "etched" look using the specified highlighting and
200 * shading colors.
202 * @param highlight A Color object for the border highlights
203 * @param shadow A Color object for the border shadows
205 * @return The Border object
207 public static Border createEtchedBorder(Color highlight, Color shadow)
209 return new EtchedBorder(highlight, shadow);
213 * Create a border with an "etched" look using the specified highlighting and
214 * shading colors.
216 * @param highlight A Color object for the border highlights
217 * @param shadow A Color object for the border shadows
219 * @return The Border object
221 public static Border createEtchedBorder(int etchType, Color highlight,
222 Color shadow)
224 return new EtchedBorder(etchType, highlight, shadow);
228 * Create a new title border specifying the text of the title, using the
229 * default border (etched), using the default text position (sitting on the
230 * top line) and default justification (left) and using the default font and
231 * text color determined by the current look and feel.
233 * @param title A String containing the text of the title
235 * @return The TitledBorder object
237 public static TitledBorder createTitledBorder(String title)
239 return new TitledBorder(title);
243 * Create a new title border with an empty title specifying the border
244 * object, using the default text position (sitting on the top line) and
245 * default justification (left) and using the default font, text color,
246 * and border determined by the current look and feel. (The Motif and Windows
247 * look and feels use an etched border; The Java look and feel use a
248 * gray border.)
250 * @param border The Border object to add the title to
252 * @return The TitledBorder object
254 public static TitledBorder createTitledBorder(Border border)
256 return new TitledBorder(border);
260 * Add a title to an existing border, specifying the text of the title, using
261 * the default positioning (sitting on the top line) and default
262 * justification (left) and using the default font and text color determined
263 * by the current look and feel.
265 * @param border The Border object to add the title to
266 * @param title A String containing the text of the title
268 * @return The TitledBorder object
270 public static TitledBorder createTitledBorder(Border border, String title)
272 return new TitledBorder(border, title);
276 * Add a title to an existing border, specifying the text of the title along
277 * with its positioning, using the default font and text color determined by
278 * the current look and feel.
280 * @param border The Border object to add the title to
281 * @param title A String containing the text of the title
282 * @param titleJustification An int specifying the left/right position of
283 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
284 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
285 * @param titlePosition An int specifying the vertical position of the text
286 * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
287 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
288 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
289 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION
290 * (top).
292 * @return The TitledBorder object
294 public static TitledBorder createTitledBorder(Border border, String title,
295 int titleJustification,
296 int titlePosition)
298 return new TitledBorder(border, title, titleJustification, titlePosition);
302 * Add a title to an existing border, specifying the text of the title along
303 * with its positioning and font, using the default text color determined by
304 * the current look and feel.
306 * @param border - the Border object to add the title to
307 * @param title - a String containing the text of the title
308 * @param titleJustification - an int specifying the left/right position of
309 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
310 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
311 * @param titlePosition - an int specifying the vertical position of the
312 * text in relation to the border -- one of: TitledBorder.ABOVE_TOP,
313 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
314 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
315 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
316 * @param titleFont - a Font object specifying the title font
318 * @return The TitledBorder object
320 public static TitledBorder createTitledBorder(Border border, String title,
321 int titleJustification,
322 int titlePosition,
323 Font titleFont)
325 return new TitledBorder(border, title, titleJustification, titlePosition,
326 titleFont);
330 * Add a title to an existing border, specifying the text of the title along
331 * with its positioning, font, and color.
333 * @param border - the Border object to add the title to
334 * @param title - a String containing the text of the title
335 * @param titleJustification - an int specifying the left/right position of
336 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
337 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
338 * @param titlePosition - an int specifying the vertical position of the text
339 * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
340 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
341 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
342 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
343 * @param titleFont - a Font object specifying the title font
344 * @param titleColor - a Color object specifying the title color
346 * @return The TitledBorder object
348 public static TitledBorder createTitledBorder(Border border, String title,
349 int titleJustification,
350 int titlePosition,
351 Font titleFont, Color titleColor)
353 return new TitledBorder(border, title, titleJustification, titlePosition,
354 titleFont, titleColor);
358 * Creates an empty border that takes up no space. (The width of the top,
359 * bottom, left, and right sides are all zero.)
361 * @return The Border object
363 public static Border createEmptyBorder()
365 return new EmptyBorder(0, 0, 0, 0);
369 * Creates an empty border that takes up no space but which does no drawing,
370 * specifying the width of the top, left, bottom, and right sides.
372 * @param top An int specifying the width of the top in pixels
373 * @param left An int specifying the width of the left side in pixels
374 * @param bottom An int specifying the width of the right side in pixels
375 * @param right An int specifying the width of the bottom in pixels
377 * @return The Border object
379 public static Border createEmptyBorder(int top, int left, int bottom,
380 int right)
382 return new EmptyBorder(top, left, bottom, right);
386 * Create a compound border with a null inside edge and a null outside edge.
388 * @return The CompoundBorder object
390 public static CompoundBorder createCompoundBorder()
392 return new CompoundBorder();
396 * Create a compound border specifying the border objects to use for the
397 * outside and inside edges.
399 * @param outsideBorder A Border object for the outer edge of the
400 * compound border
401 * @param insideBorder A Border object for the inner edge of the
402 * compound border
404 * @return The CompoundBorder object
406 public static CompoundBorder createCompoundBorder(Border outsideBorder,
407 Border insideBorder)
409 return new CompoundBorder(outsideBorder, insideBorder);
413 * Create a matte-look border using a solid color. (The difference between
414 * this border and a line border is that you can specify the individual border
415 * dimensions.)
417 * @param top
418 * An int specifying the width of the top in pixels
419 * @param left
420 * An int specifying the width of the left side in pixels
421 * @param bottom
422 * An int specifying the width of the right side in pixels
423 * @param right
424 * An int specifying the width of the bottom in pixels
425 * @param color
426 * A Color to use for the border
427 * @return The MatteBorder object
429 public static MatteBorder createMatteBorder(int top, int left, int bottom,
430 int right, Color color)
432 return new MatteBorder(top, left, bottom, right, color);
436 * Create a matte-look border that consists of multiple tiles of a specified
437 * icon. Multiple copies of the icon are placed side-by-side to fill up the
438 * border area.
440 * Note:
441 * If the icon doesn't load, the border area is painted gray.
443 * @param top An int specifying the width of the top in pixels
444 * @param left An int specifying the width of the left side in pixels
445 * @param bottom An int specifying the width of the right side in pixels
446 * @param right An int specifying the width of the bottom in pixels
447 * @param tileIcon The Icon object used for the border tiles
449 * @return The MatteBorder object
451 public static MatteBorder createMatteBorder(int top, int left, int bottom,
452 int right, Icon tileIcon)
454 return new MatteBorder(top, left, bottom, right, tileIcon);