public class javax.swing
BorderFactory


Hide details Login
Java SE 6
  

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.
version1.35 11/17/05

Methods
public static Border createBevelBorder(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.)
typean integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
returnthe Border object
public static Border createBevelBorder(int type, Color highlight, 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.
typean integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
highlighta Color object for highlights
shadowa Color object for shadows
returnthe Border object
public static Border createBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, 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.
typean integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
highlightOutera Color object for the outer edge of the highlight area
highlightInnera Color object for the inner edge of the highlight area
shadowOutera Color object for the outer edge of the shadow area
shadowInnera Color object for the inner edge of the shadow area
returnthe Border object

public static CompoundBorder createCompoundBorder()
Creates a compound border with a null inside edge and a null outside edge.
returnthe CompoundBorder object
public static CompoundBorder createCompoundBorder(Border outsideBorder, Border insideBorder)
Creates a compound border specifying the border objects to use for the outside and inside edges.
outsideBordera Border object for the outer edge of the compound border
insideBordera Border object for the inner edge of the compound border
returnthe CompoundBorder object
public static Border createEmptyBorder()
Creates an empty border that takes up no space. (The width of the top, bottom, left, and right sides are all zero.)
returnthe Border object
public static Border createEmptyBorder(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.
topan integer specifying the width of the top, in pixels
leftan integer specifying the width of the left side, in pixels
bottoman integer specifying the width of the bottom, in pixels
rightan integer specifying the width of the right side, in pixels
returnthe Border object
public static Border createEtchedBorder()
Creates a border with an "etched" look using the component's current background color for highlighting and shading.
returnthe Border object
public static Border createEtchedBorder(Color highlight, Color shadow)
Creates a border with an "etched" look using the specified highlighting and shading colors.
highlighta Color object for the border highlights
shadowa Color object for the border shadows
returnthe Border object
public static Border createEtchedBorder(int type)
Creates a border with an "etched" look using the component's current background color for highlighting and shading.
typeone of EtchedBorder.RAISED, or EtchedBorder.LOWERED
returnthe Border object
ThrowsIllegalArgumentException: if type is not either EtchedBorder.RAISED or EtchedBorder.LOWERED
since1.3
public static Border createEtchedBorder(int type, Color highlight, Color shadow)
Creates a border with an "etched" look using the specified highlighting and shading colors.
typeone of EtchedBorder.RAISED, or EtchedBorder.LOWERED
highlighta Color object for the border highlights
shadowa Color object for the border shadows
returnthe Border object
since1.3
public static Border createLineBorder(Color color)
Creates a line border withe the specified color.
colora Color to use for the line
returnthe Border object
public static Border createLineBorder(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 #createMatteBorder(int,int,int,int,Color).
colora Color to use for the line
thicknessan integer specifying the width in pixels
returnthe Border object
public static Border createLoweredBevelBorder()
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.)
returnthe Border object
public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, 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.)
topan integer specifying the width of the top, in pixels
leftan integer specifying the width of the left side, in pixels
bottoman integer specifying the width of the right side, in pixels
rightan integer specifying the width of the bottom, in pixels
colora Color to use for the border
returnthe MatteBorder object
public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, 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.
topan integer specifying the width of the top, in pixels
leftan integer specifying the width of the left side, in pixels
bottoman integer specifying the width of the right side, in pixels
rightan integer specifying the width of the bottom, in pixels
tileIconthe Icon object used for the border tiles
returnthe MatteBorder object

public static Border createRaisedBevelBorder()
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.)
returnthe Border object
public static TitledBorder createTitledBorder(String title)
Creates a new titled border with the specified title, the default border type (determined by the current look and feel), the default text position (sitting on the top line), the default justification (leading), and the default font and text color (determined by the current look and feel).
titlea String containing the text of the title
returnthe TitledBorder object
public static TitledBorder createTitledBorder(Border border)
Creates a new titled border with an empty title, the specified border object, the default text position (sitting on the top line), the default justification (leading), and the default font and text color (determined by the current look and feel).
borderthe Border object to add the title to; if null the Border is determined by the current look and feel.
returnthe TitledBorder object
public static TitledBorder createTitledBorder(Border border, String title)
Adds a title to an existing border, with default positioning (sitting on the top line), default justification (leading) and the default font and text color (determined by the current look and feel).
borderthe Border object to add the title to
titlea String containing the text of the title
returnthe TitledBorder object
public static TitledBorder createTitledBorder(Border border, String title, int titleJustification, int titlePosition)
Adds a title to an existing border, with the specified positioning and using the default font and text color (determined by the current look and feel).
borderthe Border object to add the title to
titlea String containing the text of the title
titleJustificationan 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)
titlePositionan 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)
returnthe TitledBorder object
public static TitledBorder createTitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont)
Adds a title to an existing border, with the specified positioning and font, and using the default text color (determined by the current look and feel).
borderthe Border object to add the title to
titlea String containing the text of the title
titleJustificationan 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)
titlePositionan 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)
titleFonta Font object specifying the title font
returnthe TitledBorder object
public static TitledBorder createTitledBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor)
Adds a title to an existing border, with the specified positioning, font and color.
borderthe Border object to add the title to
titlea String containing the text of the title
titleJustificationan 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)
titlePositionan 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)
titleFonta Font object specifying the title font
titleColora Color object specifying the title color
returnthe TitledBorder object