FileDocCategorySizeDatePackage
BorderFactory.javaAPI DocJava SE 5 API20154Fri Aug 26 14:57:52 BST 2005javax.swing

BorderFactory

public class BorderFactory extends Object
Factory class for vending standard Border objects. Wherever possible, this factory will hand out references to shared Border instances. For further information and examples see How to Use Borders, a section in The Java Tutorial.
version
1.30 12/19/03
author
David Kloba

Fields Summary
static final Border
sharedRaisedBevel
static final Border
sharedLoweredBevel
static final Border
sharedEtchedBorder
private static Border
sharedRaisedEtchedBorder
static final Border
emptyBorder
Constructors Summary
private BorderFactory()
Don't let anyone instantiate this class

    
Methods Summary
public static javax.swing.border.BordercreateBevelBorder(int type)
Creates a beveled border of the specified type, using brighter shades of the component's current background color for highlighting, and darker shading for shadows. (In a lowered border, shadows are on top and highlights are underneath.)

param
type an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
return
the Border object

	return createSharedBevel(type);
    
public static javax.swing.border.BordercreateBevelBorder(int type, java.awt.Color highlight, java.awt.Color shadow)
Creates a beveled border of the specified type, using the specified highlighting and shadowing. The outer edge of the highlighted area uses a brighter shade of the highlight color. The inner edge of the shadow area uses a brighter shade of the shadow color.

param
type an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
param
highlight a Color object for highlights
param
shadow a Color object for shadows
return
the Border object

        return new BevelBorder(type, highlight, shadow);
    
public static javax.swing.border.BordercreateBevelBorder(int type, java.awt.Color highlightOuter, java.awt.Color highlightInner, java.awt.Color shadowOuter, java.awt.Color shadowInner)
Creates a beveled border of the specified type, using the specified colors for the inner and outer highlight and shadow areas.

Note: The shadow inner and outer colors are switched for a lowered bevel border.

param
type an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
param
highlightOuter a Color object for the outer edge of the highlight area
param
highlightInner a Color object for the inner edge of the highlight area
param
shadowOuter a Color object for the outer edge of the shadow area
param
shadowInner a Color object for the inner edge of the shadow area
return
the Border object

        return new BevelBorder(type, highlightOuter, highlightInner, 
					shadowOuter, shadowInner);
    
public static javax.swing.border.CompoundBordercreateCompoundBorder()
Creates a compound border with a null inside edge and a null outside edge.

return
the CompoundBorder object

 
	return new CompoundBorder(); 
    
public static javax.swing.border.CompoundBordercreateCompoundBorder(javax.swing.border.Border outsideBorder, javax.swing.border.Border insideBorder)
Creates a compound border specifying the border objects to use for the outside and inside edges.

param
outsideBorder a Border object for the outer edge of the compound border
param
insideBorder a Border object for the inner edge of the compound border
return
the CompoundBorder object

 
	return new CompoundBorder(outsideBorder, insideBorder); 
    
public static javax.swing.border.BordercreateEmptyBorder()
Creates an empty border that takes up no space. (The width of the top, bottom, left, and right sides are all zero.)

return
the Border object


                                   
        
	return emptyBorder;
    
public static javax.swing.border.BordercreateEmptyBorder(int top, int left, int bottom, int right)
Creates an empty border that takes up space but which does no drawing, specifying the width of the top, left, bottom, and right sides.

param
top an integer specifying the width of the top, in pixels
param
left an integer specifying the width of the left side, in pixels
param
bottom an integer specifying the width of the bottom, in pixels
param
right an integer specifying the width of the right side, in pixels
return
the Border object

	return new EmptyBorder(top, left, bottom, right);
    
public static javax.swing.border.BordercreateEtchedBorder()
Creates a border with an "etched" look using the component's current background color for highlighting and shading.

return
the Border object


                               
           
	return sharedEtchedBorder;
    
public static javax.swing.border.BordercreateEtchedBorder(java.awt.Color highlight, java.awt.Color shadow)
Creates a border with an "etched" look using the specified highlighting and shading colors.

param
highlight a Color object for the border highlights
param
shadow a Color object for the border shadows
return
the Border object

        return new EtchedBorder(highlight, shadow);
    
public static javax.swing.border.BordercreateEtchedBorder(int type)
Creates a border with an "etched" look using the component's current background color for highlighting and shading.

param
type one of EtchedBorder.RAISED, or EtchedBorder.LOWERED
return
the Border object
exception
IllegalArgumentException if type is not either EtchedBorder.RAISED or EtchedBorder.LOWERED
since
1.3

	switch (type) {
	case EtchedBorder.RAISED:
	    if (sharedRaisedEtchedBorder == null) {
		sharedRaisedEtchedBorder = new EtchedBorder
		                           (EtchedBorder.RAISED);
	    }
	    return sharedRaisedEtchedBorder;
	case EtchedBorder.LOWERED:
	    return sharedEtchedBorder;
	default:
	    throw new IllegalArgumentException("type must be one of EtchedBorder.RAISED or EtchedBorder.LOWERED");
	}
    
public static javax.swing.border.BordercreateEtchedBorder(int type, java.awt.Color highlight, java.awt.Color shadow)
Creates a border with an "etched" look using the specified highlighting and shading colors.

param
type one of EtchedBorder.RAISED, or EtchedBorder.LOWERED
param
highlight a Color object for the border highlights
param
shadow a Color object for the border shadows
return
the Border object
since
1.3

        return new EtchedBorder(type, highlight, shadow);
    
public static javax.swing.border.BordercreateLineBorder(java.awt.Color color)
Creates a line border withe the specified color.

param
color a Color to use for the line
return
the Border object

        return new LineBorder(color, 1);
    
public static javax.swing.border.BordercreateLineBorder(java.awt.Color color, int thickness)
Creates a line border with the specified color and width. The width applies to all four sides of the border. To specify widths individually for the top, bottom, left, and right, use {@link #createMatteBorder(int,int,int,int,Color)}.

param
color a Color to use for the line
param
thickness an integer specifying the width in pixels
return
the Border object

        return new LineBorder(color, thickness);
    
public static javax.swing.border.BordercreateLoweredBevelBorder()
Creates a border with a lowered beveled edge, using brighter shades of the component's current background color for highlighting, and darker shading for shadows. (In a lowered border, shadows are on top and highlights are underneath.)

return
the Border object

        return createSharedBevel(BevelBorder.LOWERED);
    
public static javax.swing.border.MatteBordercreateMatteBorder(int top, int left, int bottom, int right, java.awt.Color color)
Creates a matte-look border using a solid color. (The difference between this border and a line border is that you can specify the individual border dimensions.)

param
top an integer specifying the width of the top, in pixels
param
left an integer specifying the width of the left side, in pixels
param
bottom an integer specifying the width of the right side, in pixels
param
right an integer specifying the width of the bottom, in pixels
param
color a Color to use for the border
return
the MatteBorder object

        return new MatteBorder(top, left, bottom, right, color);
    
public static javax.swing.border.MatteBordercreateMatteBorder(int top, int left, int bottom, int right, javax.swing.Icon tileIcon)
Creates a matte-look border that consists of multiple tiles of a specified icon. Multiple copies of the icon are placed side-by-side to fill up the border area.

Note:
If the icon doesn't load, the border area is painted gray.

param
top an integer specifying the width of the top, in pixels
param
left an integer specifying the width of the left side, in pixels
param
bottom an integer specifying the width of the right side, in pixels
param
right an integer specifying the width of the bottom, in pixels
param
tileIcon the Icon object used for the border tiles
return
the MatteBorder object

        return new MatteBorder(top, left, bottom, right, tileIcon);
    
public static javax.swing.border.BordercreateRaisedBevelBorder()
Creates a border with a raised beveled edge, using brighter shades of the component's current background color for highlighting, and darker shading for shadows. (In a raised border, highlights are on top and shadows are underneath.)

return
the Border object


                                                  
        
        return createSharedBevel(BevelBorder.RAISED);
    
static javax.swing.border.BordercreateSharedBevel(int type)

	if(type == BevelBorder.RAISED) {
	    return sharedRaisedBevel;
	} else if(type == BevelBorder.LOWERED) {
	    return sharedLoweredBevel;
	}
	return null;
    
public static javax.swing.border.TitledBordercreateTitledBorder(java.lang.String title)
Creates a new title border specifying the text of the title, using the default border (etched), using the default text position (sitting on the top line) and default justification (leading) and using the default font and text color determined by the current look and feel.

param
title a String containing the text of the title
return
the TitledBorder object

        return new TitledBorder(title);
    
public static javax.swing.border.TitledBordercreateTitledBorder(javax.swing.border.Border border)
Creates a new title border with an empty title specifying the border object, using the default text position (sitting on the top line) and default justification (leading) and using the default font, and text color.

param
border the Border object to add the title to, if null the Border is determined by the current look and feel.
return
the TitledBorder object

        return new TitledBorder(border);
    
public static javax.swing.border.TitledBordercreateTitledBorder(javax.swing.border.Border border, java.lang.String title)
Adds a title to an existing border, specifying the text of the title, using the default positioning (sitting on the top line) and default justification (leading) and using the default font and text color determined by the current look and feel.

param
border the Border object to add the title to
param
title a String containing the text of the title
return
the TitledBorder object

        return new TitledBorder(border, title);
    
public static javax.swing.border.TitledBordercreateTitledBorder(javax.swing.border.Border border, java.lang.String title, int titleJustification, int titlePosition)
Adds a title to an existing border, specifying the text of the title along with its positioning, using the default font and text color determined by the current look and feel.

param
border the Border object to add the title to
param
title a String containing the text of the title
param
titleJustification an integer specifying the justification of the title -- one of the following:
  • TitledBorder.LEFT
  • TitledBorder.CENTER
  • TitledBorder.RIGHT
  • TitledBorder.LEADING
  • TitledBorder.TRAILING
  • TitledBorder.DEFAULT_JUSTIFICATION (leading)
param
titlePosition an integer specifying the vertical position of the text in relation to the border -- one of the following:
  • TitledBorder.ABOVE_TOP
  • TitledBorder.TOP (sitting on the top line)
  • TitledBorder.BELOW_TOP
  • TitledBorder.ABOVE_BOTTOM
  • TitledBorder.BOTTOM (sitting on the bottom line)
  • TitledBorder.BELOW_BOTTOM
  • TitledBorder.DEFAULT_POSITION (top)
return
the TitledBorder object

        return new TitledBorder(border, title, titleJustification,
                        titlePosition);
    
public static javax.swing.border.TitledBordercreateTitledBorder(javax.swing.border.Border border, java.lang.String title, int titleJustification, int titlePosition, java.awt.Font titleFont)
Adds a title to an existing border, specifying the text of the title along with its positioning and font, using the default text color determined by the current look and feel.

param
border the Border object to add the title to
param
title a String containing the text of the title
param
titleJustification an integer specifying the justification of the title -- one of the following:
  • TitledBorder.LEFT
  • TitledBorder.CENTER
  • TitledBorder.RIGHT
  • TitledBorder.LEADING
  • TitledBorder.TRAILING
  • TitledBorder.DEFAULT_JUSTIFICATION (leading)
param
titlePosition an integer specifying the vertical position of the text in relation to the border -- one of the following:
  • TitledBorder.ABOVE_TOP
  • TitledBorder.TOP (sitting on the top line)
  • TitledBorder.BELOW_TOP
  • TitledBorder.ABOVE_BOTTOM
  • TitledBorder.BOTTOM (sitting on the bottom line)
  • TitledBorder.BELOW_BOTTOM
  • TitledBorder.DEFAULT_POSITION (top)
param
titleFont a Font object specifying the title font
return
the TitledBorder object

        return new TitledBorder(border, title, titleJustification,
                        titlePosition, titleFont);
    
public static javax.swing.border.TitledBordercreateTitledBorder(javax.swing.border.Border border, java.lang.String title, int titleJustification, int titlePosition, java.awt.Font titleFont, java.awt.Color titleColor)
Adds a title to an existing border, specifying the text of the title along with its positioning, font, and color.

param
border the Border object to add the title to
param
title a String containing the text of the title
param
titleJustification an integer specifying the justification of the title -- one of the following:
  • TitledBorder.LEFT
  • TitledBorder.CENTER
  • TitledBorder.RIGHT
  • TitledBorder.LEADING
  • TitledBorder.TRAILING
  • TitledBorder.DEFAULT_JUSTIFICATION (leading)
param
titlePosition an integer specifying the vertical position of the text in relation to the border -- one of the following:
  • TitledBorder.ABOVE_TOP
  • TitledBorder.TOP (sitting on the top line)
  • TitledBorder.BELOW_TOP
  • TitledBorder.ABOVE_BOTTOM
  • TitledBorder.BOTTOM (sitting on the bottom line)
  • TitledBorder.BELOW_BOTTOM
  • TitledBorder.DEFAULT_POSITION (top)
param
titleFont a Font object specifying the title font
param
titleColor a Color object specifying the title color
return
the TitledBorder object

        return new TitledBorder(border, title, titleJustification,
                        titlePosition, titleFont, titleColor);