OSDN Git Service

* javax/swing/RepaintManager.java
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / BorderFactory.java
1 /* BorderFactory.java
2    Copyright (C) 2002 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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.
10
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.
15
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.
20
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.
25
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. */
37
38
39 package javax.swing;
40
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;
51
52 public class BorderFactory
53 {
54   /**
55    * Creates a line border withe the specified color.
56    *
57    * @param color A color to use for the line.
58    *
59    * @return The Border object
60    */ 
61   public static Border createLineBorder(Color color)
62   {
63     return null;
64   }
65
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).
71    *
72    * @param color A color to use for the line.
73    * @param thickness An int specifying the width in pixels.
74    *
75    * @return The Border object
76    */ 
77   public static Border createLineBorder (Color color, int thickness)
78   {
79     return new LineBorder (color, thickness);
80   }
81
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.)
87    *
88    * @return The Border object
89    */ 
90   public static Border createRaisedBevelBorder ()
91   {
92     return new BevelBorder (BevelBorder.RAISED);
93   }
94
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.)
100    *
101    * @return The Border object
102    */ 
103   public static Border createLoweredBevelBorder ()
104   {
105     return new BevelBorder (BevelBorder.LOWERED);
106   }
107
108   /**
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.).
113    *
114    * @param type An int specifying either BevelBorder.LOWERED or
115    * BevelBorder.RAISED
116    *
117    * @Return The Border object
118    */ 
119   public static Border createBevelBorder (int type)
120   {
121     return new BevelBorder (type);
122   }
123
124   /**
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.
129    *
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
134    *
135    * @return The Border object
136   */ 
137   public static Border createBevelBorder (int type, Color highlight,
138                                           Color shadow)
139   {
140     return new BevelBorder (type, highlight, shadow);
141   }
142
143   /**
144    * Create a beveled border of the specified type, using the specified colors
145    * for the inner and outer highlight and shadow areas.
146    *
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
155    *
156    * @return The Border object
157    */ 
158   public static Border createBevelBorder (int type, Color highlightOuter,
159                                           Color highlightInner,
160                                           Color shadowOuter, Color shadowInner)
161   {
162     return new BevelBorder (type, highlightOuter, highlightInner, shadowOuter,
163                             shadowInner);
164   }
165
166   /**
167    * Create a border with an "etched" look using the component's current
168    * background color for highlighting and shading.
169    *
170    * @return The Border object
171    */ 
172   public static Border createEtchedBorder ()
173   {
174     return new EtchedBorder ();
175   }
176
177   /**
178    * Create a border with an "etched" look using the component's current
179    * background color for highlighting and shading.
180    *
181    * @return The Border object
182    */ 
183   public static Border createEtchedBorder (int etchType)
184   {
185     return new EtchedBorder (etchType);
186   }
187
188   /**
189    * Create a border with an "etched" look using the specified highlighting and
190    * shading colors.
191    *
192    * @param highlight A Color object for the border highlights
193    * @param shadow A Color object for the border shadows
194    *
195    * @return The Border object
196    */ 
197   public static Border createEtchedBorder (Color highlight, Color shadow)
198   {
199     return new EtchedBorder (highlight, shadow);
200   }
201
202   /**
203    * Create a border with an "etched" look using the specified highlighting and
204    * shading colors.
205    *
206    * @param highlight A Color object for the border highlights
207    * @param shadow A Color object for the border shadows
208    *
209    * @return The Border object
210    */ 
211   public static Border createEtchedBorder (int etchType, Color highlight,
212                                            Color shadow)
213   {
214     return new EtchedBorder (etchType, highlight, shadow);
215   }
216
217   /**
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.
222    *
223    * @param title A String containing the text of the title
224    *
225    * @return The TitledBorder object
226    */ 
227   public static TitledBorder createTitledBorder (String title)
228   {
229     return new TitledBorder (title);
230   }
231
232   /**
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.)
239    *
240    * @param border The Border object to add the title to
241    *
242    * @return The TitledBorder object
243    */ 
244   public static TitledBorder createTitledBorder (Border border)
245   {
246     return new TitledBorder (border);
247   }
248
249   /**
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.
254    *
255    * @param order The Border object to add the title to
256    * @param title A String containing the text of the title
257    *
258    * @return The TitledBorder object
259    */ 
260   public static TitledBorder createTitledBorder (Border border, String title)
261   {
262     return new TitledBorder (border, title);
263   }
264
265   /**
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.
269    *
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).
280    *
281    * @return The TitledBorder object
282    */ 
283   public static TitledBorder createTitledBorder (Border border, String title,
284                                                 int titleJustification,
285                                                 int titlePosition)
286   {
287     return new TitledBorder (border, title, titleJustification, titlePosition);
288   }
289
290   /**
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.
294    *
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
306    *
307    * @return The TitledBorder object
308    */ 
309   public static TitledBorder createTitledBorder (Border border, String title,
310                                                  int titleJustification,
311                                                  int titlePosition,
312                                                  Font titleFont)
313   {
314     return new TitledBorder (border, title, titleJustification, titlePosition,
315                              titleFont);
316   }
317
318   /**
319    * Add a title to an existing border, specifying the text of the title along
320    * with its positioning, font, and color.
321    *
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
334    *
335    * @return The TitledBorder object
336    */ 
337   public static TitledBorder createTitledBorder (Border border,
338                                                  String title,
339                                                  int titleJustification,
340                                                  int titlePosition,
341                                                  Font titleFont,
342                                                  Color titleColor)
343   {
344     return new TitledBorder (border, title, titleJustification, titlePosition,
345                              titleFont, titleColor);
346   }
347
348   /**
349    * Creates an empty border that takes up no space. (The width of the top,
350    * bottom, left, and right sides are all zero.)
351    *
352    * @return The Border object
353    */ 
354   public static Border createEmptyBorder ()
355   {
356     return new EmptyBorder (0, 0, 0, 0);
357   }
358
359   /**
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.
362    *
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
367    *
368    * @return The Border object
369    */ 
370   public static Border createEmptyBorder (int top, int left, int bottom,
371                                           int right)
372   {
373     return new EmptyBorder (top, left, bottom, right);
374   }
375
376   /**
377    * Create a compound border with a null inside edge and a null outside edge.
378    *
379    * @return The CompoundBorder object
380    */ 
381   public static CompoundBorder createCompoundBorder ()
382   {
383     return new CompoundBorder ();
384   }
385
386   /**
387    * Create a compound border specifying the border objects to use for the
388    * outside and inside edges.
389    *
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
394    *
395    * @return The CompoundBorder object
396    */ 
397   public static CompoundBorder createCompoundBorder (Border outsideBorder,
398                                                      Border insideBorder)
399   {
400     return new CompoundBorder (outsideBorder, insideBorder);
401   }
402
403   /**
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.)
407    *
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
413    *
414    * @return The MatteBorder object
415    */ 
416   public static MatteBorder createMatteBorder (int top, int left, int bottom,
417                                                int right, Color color)
418   {
419     return new MatteBorder (top, left, bottom, right, color);
420   }
421
422   /**
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.
426    *
427    * Note:
428    * If the icon doesn't load, the border area is painted gray.
429    *
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
435    *
436    * @return The MatteBorder object
437    */ 
438   public static MatteBorder createMatteBorder (int top, int left, int bottom,
439                                                int right, Icon tileIcon)
440   {
441     return new MatteBorder (top, left, bottom, right, tileIcon);
442   }
443 }