2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / javax / swing / BorderFactory.java
blob1cc6cbf420d4ac879b86c9c6e55ad5be6311ada0
1 /* BorderFactory.java
2 Copyright (C) 2002 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;
43 import javax.swing.border.BevelBorder;
44 import javax.swing.border.Border;
45 import javax.swing.border.CompoundBorder;
46 import javax.swing.border.EmptyBorder;
47 import javax.swing.border.EtchedBorder;
48 import javax.swing.border.LineBorder;
49 import javax.swing.border.MatteBorder;
50 import javax.swing.border.TitledBorder;
52 public class BorderFactory
54 /**
55 * Creates a line border withe the specified color.
57 * @param color A color to use for the line.
59 * @return The Border object
60 */
61 public static Border createLineBorder(Color color)
63 return null;
66 /**
67 * Creates a line border withe the specified color and width. The width
68 * applies to all 4 sides of the border. To specify widths individually for
69 * the top, bottom, left, and right, use
70 * createMatteBorder(int,int,int,int,Color).
72 * @param color A color to use for the line.
73 * @param thickness An int specifying the width in pixels.
75 * @return The Border object
76 */
77 public static Border createLineBorder (Color color, int thickness)
79 return new LineBorder (color, thickness);
82 /**
83 * Created a border with a raised beveled edge, using brighter shades of
84 * the component's current background color for highlighting, and darker
85 * shading for shadows. (In a raised border, highlights are on top and
86 * shadows are underneath.)
88 * @return The Border object
89 */
90 public static Border createRaisedBevelBorder ()
92 return new BevelBorder (BevelBorder.RAISED);
95 /**
96 * Created a border with a lowered beveled edge, using brighter shades of
97 * the component's current background color for highlighting, and darker
98 * shading for shadows. (In a lowered border, shadows are on top and
99 * highlights are underneath.)
101 * @return The Border object
103 public static Border createLoweredBevelBorder ()
105 return new BevelBorder (BevelBorder.LOWERED);
109 * Create a beveled border of the specified type, using brighter shades of
110 * the component's current background color for highlighting, and darker
111 * shading for shadows. (In a lowered border, shadows are on top and
112 * highlights are underneath.).
114 * @param type An int specifying either BevelBorder.LOWERED or
115 * BevelBorder.RAISED
117 * @Return The Border object
119 public static Border createBevelBorder (int type)
121 return new BevelBorder (type);
125 * Create a beveled border of the specified type, using the specified
126 * highlighting and shadowing. The outer edge of the highlighted area uses
127 * a brighter shade of the highlight color. The inner edge of the shadow
128 * area uses a brighter shade of the shadaw color.
130 * @param type An int specifying either BevelBorder.LOWERED or
131 * BevelBorder.RAISED
132 * @param highlight A Color object for highlights
133 * @param shadow A Color object for shadows
135 * @return The Border object
137 public static Border createBevelBorder (int type, Color highlight,
138 Color shadow)
140 return new BevelBorder (type, highlight, shadow);
144 * Create a beveled border of the specified type, using the specified colors
145 * for the inner and outer highlight and shadow areas.
147 * @param type An int specifying either BevelBorder.LOWERED or
148 * BevelBorder.RAISED
149 * @param highlightOuter A Color object for the outer edge of the
150 * highlight area
151 * @param highlightInner A Color object for the inner edge of the
152 * highlight area
153 * @param shadowOuter A Color object for the outer edge of the shadow area
154 * @param shadowInner A Color object for the inner edge of the shadow area
156 * @return The Border object
158 public static Border createBevelBorder (int type, Color highlightOuter,
159 Color highlightInner,
160 Color shadowOuter, Color shadowInner)
162 return new BevelBorder (type, highlightOuter, highlightInner, shadowOuter,
163 shadowInner);
167 * Create a border with an "etched" look using the component's current
168 * background color for highlighting and shading.
170 * @return The Border object
172 public static Border createEtchedBorder ()
174 return new EtchedBorder ();
178 * Create a border with an "etched" look using the component's current
179 * background color for highlighting and shading.
181 * @return The Border object
183 public static Border createEtchedBorder (int etchType)
185 return new EtchedBorder (etchType);
189 * Create a border with an "etched" look using the specified highlighting and
190 * shading colors.
192 * @param highlight A Color object for the border highlights
193 * @param shadow A Color object for the border shadows
195 * @return The Border object
197 public static Border createEtchedBorder (Color highlight, Color shadow)
199 return new EtchedBorder (highlight, shadow);
203 * Create a border with an "etched" look using the specified highlighting and
204 * shading colors.
206 * @param highlight A Color object for the border highlights
207 * @param shadow A Color object for the border shadows
209 * @return The Border object
211 public static Border createEtchedBorder (int etchType, Color highlight,
212 Color shadow)
214 return new EtchedBorder (etchType, highlight, shadow);
218 * Create a new title border specifying the text of the title, using the
219 * default border (etched), using the default text position (sitting on the
220 * top line) and default justification (left) and using the default font and
221 * text color determined by the current look and feel.
223 * @param title A String containing the text of the title
225 * @return The TitledBorder object
227 public static TitledBorder createTitledBorder (String title)
229 return new TitledBorder (title);
233 * Create a new title border with an empty title specifying the border
234 * object, using the default text position (sitting on the top line) and
235 * default justification (left) and using the default font, text color,
236 * and border determined by the current look and feel. (The Motif and Windows
237 * look and feels use an etched border; The Java look and feel use a
238 * gray border.)
240 * @param border The Border object to add the title to
242 * @return The TitledBorder object
244 public static TitledBorder createTitledBorder (Border border)
246 return new TitledBorder (border);
250 * Add a title to an existing border, specifying the text of the title, using
251 * the default positioning (sitting on the top line) and default
252 * justification (left) and using the default font and text color determined
253 * by the current look and feel.
255 * @param order The Border object to add the title to
256 * @param title A String containing the text of the title
258 * @return The TitledBorder object
260 public static TitledBorder createTitledBorder (Border border, String title)
262 return new TitledBorder (border, title);
266 * Add a title to an existing border, specifying the text of the title along
267 * with its positioning, using the default font and text color determined by
268 * the current look and feel.
270 * @param border The Border object to add the title to
271 * @param title A String containing the text of the title
272 * @param titleJustification An int specifying the left/right position of
273 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
274 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
275 * @param titlePosition An int specifying the vertical position of the text
276 * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
277 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
278 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
279 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
281 * @return The TitledBorder object
283 public static TitledBorder createTitledBorder (Border border, String title,
284 int titleJustification,
285 int titlePosition)
287 return new TitledBorder (border, title, titleJustification, titlePosition);
291 * Add a title to an existing border, specifying the text of the title along
292 * with its positioning and font, using the default text color determined by
293 * the current look and feel.
295 * @param border - the Border object to add the title to
296 * @param title - a String containing the text of the title
297 * @param titleJustification - an int specifying the left/right position of
298 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
299 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
300 * @param titlePosition - an int specifying the vertical position of the
301 * text in relation to the border -- one of: TitledBorder.ABOVE_TOP,
302 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
303 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
304 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
305 * @param titleFont - a Font object specifying the title font
307 * @return The TitledBorder object
309 public static TitledBorder createTitledBorder (Border border, String title,
310 int titleJustification,
311 int titlePosition,
312 Font titleFont)
314 return new TitledBorder (border, title, titleJustification, titlePosition,
315 titleFont);
319 * Add a title to an existing border, specifying the text of the title along
320 * with its positioning, font, and color.
322 * @param border - the Border object to add the title to
323 * @param title - a String containing the text of the title
324 * @param titleJustification - an int specifying the left/right position of
325 * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
326 * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
327 * @param titlePosition - an int specifying the vertical position of the text
328 * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
329 * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
330 * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
331 * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
332 * @param titleFont - a Font object specifying the title font
333 * @param titleColor - a Color object specifying the title color
335 * @return The TitledBorder object
337 public static TitledBorder createTitledBorder (Border border,
338 String title,
339 int titleJustification,
340 int titlePosition,
341 Font titleFont,
342 Color titleColor)
344 return new TitledBorder (border, title, titleJustification, titlePosition,
345 titleFont, titleColor);
349 * Creates an empty border that takes up no space. (The width of the top,
350 * bottom, left, and right sides are all zero.)
352 * @return The Border object
354 public static Border createEmptyBorder ()
356 return new EmptyBorder (0, 0, 0, 0);
360 * Creates an empty border that takes up no space but which does no drawing,
361 * specifying the width of the top, left, bottom, and right sides.
363 * @param top An int specifying the width of the top in pixels
364 * @param left An int specifying the width of the left side in pixels
365 * @param bottom An int specifying the width of the right side in pixels
366 * @param right An int specifying the width of the bottom in pixels
368 * @return The Border object
370 public static Border createEmptyBorder (int top, int left, int bottom,
371 int right)
373 return new EmptyBorder (top, left, bottom, right);
377 * Create a compound border with a null inside edge and a null outside edge.
379 * @return The CompoundBorder object
381 public static CompoundBorder createCompoundBorder ()
383 return new CompoundBorder ();
387 * Create a compound border specifying the border objects to use for the
388 * outside and inside edges.
390 * @param outsideBorder A Border object for the outer edge of the
391 * compound border
392 * @param insideBorder A Border object for the inner edge of the
393 * compound border
395 * @return The CompoundBorder object
397 public static CompoundBorder createCompoundBorder (Border outsideBorder,
398 Border insideBorder)
400 return new CompoundBorder (outsideBorder, insideBorder);
404 * Create a matte-look border using a solid color. (The difference between
405 * this border and a line border is that you can specify the individual
406 * border dimensions.)
408 * @param top An int specifying the width of the top in pixels
409 * @param left An int specifying the width of the left side in pixels
410 * @param bottom An int specifying the width of the right side in pixels
411 * @param right An int specifying the width of the bottom in pixels
412 * @param color A Color to use for the border
414 * @return The MatteBorder object
416 public static MatteBorder createMatteBorder (int top, int left, int bottom,
417 int right, Color color)
419 return new MatteBorder (top, left, bottom, right, color);
423 * Create a matte-look border that consists of multiple tiles of a specified
424 * icon. Multiple copies of the icon are placed side-by-side to fill up the
425 * border area.
427 * Note:
428 * If the icon doesn't load, the border area is painted gray.
430 * @param top An int specifying the width of the top in pixels
431 * @param left An int specifying the width of the left side in pixels
432 * @param bottom An int specifying the width of the right side in pixels
433 * @param right An int specifying the width of the bottom in pixels
434 * @param tileIcon The Icon object used for the border tiles
436 * @return The MatteBorder object
438 public static MatteBorder createMatteBorder (int top, int left, int bottom,
439 int right, Icon tileIcon)
441 return new MatteBorder (top, left, bottom, right, tileIcon);