This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / libjava / javax / swing / BorderFactory.java
blob4f0a1ee4e2eb2764e5ac18dfab33252313de4e12
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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 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 public class BorderFactory
55 private BorderFactory()
57 // Do nothing.
60 /**
61 * Creates a line border withe the specified color.
63 * @param color A color to use for the line.
65 * @return The Border object
66 */
67 public static Border createLineBorder(Color color)
69 return null;
72 /**
73 * Creates a line border withe the specified color and width. The width
74 * applies to all 4 sides of the border. To specify widths individually for
75 * the top, bottom, left, and right, use
76 * createMatteBorder(int,int,int,int,Color).
78 * @param color A color to use for the line.
79 * @param thickness An int specifying the width in pixels.
81 * @return The Border object
82 */
83 public static Border createLineBorder (Color color, int thickness)
85 return new LineBorder (color, thickness);
88 /**
89 * Created a border with a raised beveled edge, using brighter shades of
90 * the component's current background color for highlighting, and darker
91 * shading for shadows. (In a raised border, highlights are on top and
92 * shadows are underneath.)
94 * @return The Border object
95 */
96 public static Border createRaisedBevelBorder ()
98 return new BevelBorder (BevelBorder.RAISED);
102 * Created a border with a lowered beveled edge, using brighter shades of
103 * the component's current background color for highlighting, and darker
104 * shading for shadows. (In a lowered border, shadows are on top and
105 * highlights are underneath.)
107 * @return The Border object
109 public static Border createLoweredBevelBorder ()
111 return new BevelBorder (BevelBorder.LOWERED);
115 * Create a beveled border of the specified type, using brighter shades of
116 * the component's current background color for highlighting, and darker
117 * shading for shadows. (In a lowered border, shadows are on top and
118 * highlights are underneath.).
120 * @param type An int specifying either BevelBorder.LOWERED or
121 * BevelBorder.RAISED
123 * @Return The Border object
125 public static Border createBevelBorder (int type)
127 return new BevelBorder (type);
131 * Create a beveled border of the specified type, using the specified
132 * highlighting and shadowing. The outer edge of the highlighted area uses
133 * a brighter shade of the highlight color. The inner edge of the shadow
134 * area uses a brighter shade of the shadaw color.
136 * @param type An int specifying either BevelBorder.LOWERED or
137 * BevelBorder.RAISED
138 * @param highlight A Color object for highlights
139 * @param shadow A Color object for shadows
141 * @return The Border object
143 public static Border createBevelBorder (int type, Color highlight,
144 Color shadow)
146 return new BevelBorder (type, highlight, shadow);
150 * Create a beveled border of the specified type, using the specified colors
151 * for the inner and outer highlight and shadow areas.
153 * @param type An int specifying either BevelBorder.LOWERED or
154 * BevelBorder.RAISED
155 * @param highlightOuter A Color object for the outer edge of the
156 * highlight area
157 * @param highlightInner A Color object for the inner edge of the
158 * highlight area
159 * @param shadowOuter A Color object for the outer edge of the shadow area
160 * @param shadowInner A Color object for the inner edge of the shadow area
162 * @return The Border object
164 public static Border createBevelBorder (int type, Color highlightOuter,
165 Color highlightInner,
166 Color shadowOuter, Color shadowInner)
168 return new BevelBorder (type, highlightOuter, highlightInner, shadowOuter,
169 shadowInner);
173 * Create a border with an "etched" look using the component's current
174 * background color for highlighting and shading.
176 * @return The Border object
178 public static Border createEtchedBorder ()
180 return new EtchedBorder ();
184 * Create a border with an "etched" look using the component's current
185 * background color for highlighting and shading.
187 * @return The Border object
189 public static Border createEtchedBorder (int etchType)
191 return new EtchedBorder (etchType);
195 * Create a border with an "etched" look using the specified highlighting and
196 * shading colors.
198 * @param highlight A Color object for the border highlights
199 * @param shadow A Color object for the border shadows
201 * @return The Border object
203 public static Border createEtchedBorder (Color highlight, Color shadow)
205 return new EtchedBorder (highlight, shadow);
209 * Create a border with an "etched" look using the specified highlighting and
210 * shading colors.
212 * @param highlight A Color object for the border highlights
213 * @param shadow A Color object for the border shadows
215 * @return The Border object
217 public static Border createEtchedBorder (int etchType, Color highlight,
218 Color shadow)
220 return new EtchedBorder (etchType, highlight, shadow);
224 * Create a new title border specifying the text of the title, using the
225 * default border (etched), using the default text position (sitting on the
226 * top line) and default justification (left) and using the default font and
227 * text color determined by the current look and feel.
229 * @param title A String containing the text of the title
231 * @return The TitledBorder object
233 public static TitledBorder createTitledBorder (String title)
235 return new TitledBorder (title);
239 * Create a new title border with an empty title specifying the border
240 * object, using the default text position (sitting on the top line) and
241 * default justification (left) and using the default font, text color,
242 * and border determined by the current look and feel. (The Motif and Windows
243 * look and feels use an etched border; The Java look and feel use a
244 * gray border.)
246 * @param border The Border object to add the title to
248 * @return The TitledBorder object
250 public static TitledBorder createTitledBorder (Border border)
252 return new TitledBorder (border);
256 * Add a title to an existing border, specifying the text of the title, using
257 * the default positioning (sitting on the top line) and default
258 * justification (left) and using the default font and text color determined
259 * by the current look and feel.
261 * @param order The Border object to add the title to
262 * @param title A String containing the text of the title
264 * @return The TitledBorder object
266 public static TitledBorder createTitledBorder (Border border, String title)
268 return new TitledBorder (border, title);
272 * Add a title to an existing border, specifying the text of the title along
273 * with its positioning, using the default font and text color determined by
274 * the current look and feel.
276 * @param border The Border object to add the title to
277 * @param title A String containing the text of the title
278 * @param titleJustification An int specifying the left/right position of
279 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
280 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
281 * @param titlePosition An int specifying the vertical position of the text
282 * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
283 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
284 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
285 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
287 * @return The TitledBorder object
289 public static TitledBorder createTitledBorder (Border border, String title,
290 int titleJustification,
291 int titlePosition)
293 return new TitledBorder (border, title, titleJustification, titlePosition);
297 * Add a title to an existing border, specifying the text of the title along
298 * with its positioning and font, using the default text color determined by
299 * the current look and feel.
301 * @param border - the Border object to add the title to
302 * @param title - a String containing the text of the title
303 * @param titleJustification - an int specifying the left/right position of
304 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
305 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
306 * @param titlePosition - an int specifying the vertical position of the
307 * text in relation to the border -- one of: TitledBorder.ABOVE_TOP,
308 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
309 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
310 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
311 * @param titleFont - a Font object specifying the title font
313 * @return The TitledBorder object
315 public static TitledBorder createTitledBorder (Border border, String title,
316 int titleJustification,
317 int titlePosition,
318 Font titleFont)
320 return new TitledBorder (border, title, titleJustification, titlePosition,
321 titleFont);
325 * Add a title to an existing border, specifying the text of the title along
326 * with its positioning, font, and color.
328 * @param border - the Border object to add the title to
329 * @param title - a String containing the text of the title
330 * @param titleJustification - an int specifying the left/right position of
331 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
332 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
333 * @param titlePosition - an int specifying the vertical position of the text
334 * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
335 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
336 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
337 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
338 * @param titleFont - a Font object specifying the title font
339 * @param titleColor - a Color object specifying the title color
341 * @return The TitledBorder object
343 public static TitledBorder createTitledBorder (Border border,
344 String title,
345 int titleJustification,
346 int titlePosition,
347 Font titleFont,
348 Color titleColor)
350 return new TitledBorder (border, title, titleJustification, titlePosition,
351 titleFont, titleColor);
355 * Creates an empty border that takes up no space. (The width of the top,
356 * bottom, left, and right sides are all zero.)
358 * @return The Border object
360 public static Border createEmptyBorder ()
362 return new EmptyBorder (0, 0, 0, 0);
366 * Creates an empty border that takes up no space but which does no drawing,
367 * specifying the width of the top, left, bottom, and right sides.
369 * @param top An int specifying the width of the top in pixels
370 * @param left An int specifying the width of the left side in pixels
371 * @param bottom An int specifying the width of the right side in pixels
372 * @param right An int specifying the width of the bottom in pixels
374 * @return The Border object
376 public static Border createEmptyBorder (int top, int left, int bottom,
377 int right)
379 return new EmptyBorder (top, left, bottom, right);
383 * Create a compound border with a null inside edge and a null outside edge.
385 * @return The CompoundBorder object
387 public static CompoundBorder createCompoundBorder ()
389 return new CompoundBorder ();
393 * Create a compound border specifying the border objects to use for the
394 * outside and inside edges.
396 * @param outsideBorder A Border object for the outer edge of the
397 * compound border
398 * @param insideBorder A Border object for the inner edge of the
399 * compound border
401 * @return The CompoundBorder object
403 public static CompoundBorder createCompoundBorder (Border outsideBorder,
404 Border insideBorder)
406 return new CompoundBorder (outsideBorder, insideBorder);
410 * Create a matte-look border using a solid color. (The difference between
411 * this border and a line border is that you can specify the individual
412 * border dimensions.)
414 * @param top An int specifying the width of the top in pixels
415 * @param left An int specifying the width of the left side in pixels
416 * @param bottom An int specifying the width of the right side in pixels
417 * @param right An int specifying the width of the bottom in pixels
418 * @param color A Color to use for the border
420 * @return The MatteBorder object
422 public static MatteBorder createMatteBorder (int top, int left, int bottom,
423 int right, Color color)
425 return new MatteBorder (top, left, bottom, right, color);
429 * Create a matte-look border that consists of multiple tiles of a specified
430 * icon. Multiple copies of the icon are placed side-by-side to fill up the
431 * border area.
433 * Note:
434 * If the icon doesn't load, the border area is painted gray.
436 * @param top An int specifying the width of the top in pixels
437 * @param left An int specifying the width of the left side in pixels
438 * @param bottom An int specifying the width of the right side in pixels
439 * @param right An int specifying the width of the bottom in pixels
440 * @param tileIcon The Icon object used for the border tiles
442 * @return The MatteBorder object
444 public static MatteBorder createMatteBorder (int top, int left, int bottom,
445 int right, Icon tileIcon)
447 return new MatteBorder (top, left, bottom, right, tileIcon);