APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class BorderFactory

extends Object
Class Inheritance
Imports
java.awt.BasicStroke, .Color, .Font, .Paint, javax.swing.border.*

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.
Author
David Kloba
Since
1.2

Field Summary

Modifier and TypeField and Description
pack-priv static final Border
private static Border
sharedDashedBorder

/ DashedBorder ////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

pack-priv static final Border
pack-priv static final Border
pack-priv static final Border
sharedRaisedBevel

/ BevelBorder ///////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////

private static Border
private static Border
private static Border
sharedSoftRaisedBevel

/ SoftBevelBorder /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

Constructor Summary

AccessConstructor and Description
private
BorderFactory()

Don't let anyone instantiate this class

Method Summary

Modifier and TypeMethod and Description
public static Border

Returns:

the Border object
createBevelBorder
(int
an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
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.

public static Border

Returns:

the Border object
createBevelBorder
(int
an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
type
,
Color
a Color object for highlights
highlight
,
Color
a Color object for shadows
shadow
)

Creates a beveled border of the specified type, using the specified highlighting and shadowing.

public static Border

Returns:

the Border object
createBevelBorder
(int
an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED
type
,
Color
a Color object for the outer edge of the highlight area
highlightOuter
,
Color
a Color object for the inner edge of the highlight area
highlightInner
,
Color
a Color object for the outer edge of the shadow area
shadowOuter
,
Color
a Color object for the inner edge of the shadow area
shadowInner
)

Creates a beveled border of the specified type, using the specified colors for the inner and outer highlight and shadow areas.

public static CompoundBorder

Returns:

the CompoundBorder object
createCompoundBorder
()

Creates a compound border with a null inside edge and a null outside edge.

public static CompoundBorder

Returns:

the CompoundBorder object
createCompoundBorder
(Border
a Border object for the outer edge of the compound border
outsideBorder
,
Border
a Border object for the inner edge of the compound border
insideBorder
)

Creates a compound border specifying the border objects to use for the outside and inside edges.

public static Border

Returns:

the Border object
createDashedBorder
(Paint
the Paint object used to generate a color
paint
)

Creates a dashed border of the specified paint.

public static Border

Returns:

the Border object
createDashedBorder
(Paint
the Paint object used to generate a color
paint
,
float
the relative length of a dash line
length
,
float
the relative spacing between dash lines
spacing
)

Creates a dashed border of the specified paint, relative length, and relative spacing.

public static Border

Returns:

the Border object
createDashedBorder
(Paint
the Paint object used to generate a color
paint
,
float
the width of a dash line
thickness
,
float
the relative length of a dash line
length
,
float
the relative spacing between dash lines
spacing
,
boolean
whether or not line ends should be round
rounded
)

Creates a dashed border of the specified paint, thickness, line shape, relative length, and relative spacing.

public static Border

Returns:

the Border object
createEmptyBorder
()

Creates an empty border that takes up no space.

public static Border

Returns:

the Border object
createEmptyBorder
(int
an integer specifying the width of the top, in pixels
top
,
int
an integer specifying the width of the left side, in pixels
left
,
int
an integer specifying the width of the bottom, in pixels
bottom
,
int
an integer specifying the width of the right side, in pixels
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.

public static Border

Returns:

the Border object
createEtchedBorder
()

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

public static Border

Returns:

the Border object
createEtchedBorder
(Color
a Color object for the border highlights
highlight
,
Color
a Color object for the border shadows
shadow
)

Creates a border with an "etched" look using the specified highlighting and shading colors.

public static Border

Returns:

the Border object
createEtchedBorder
(int
one of EtchedBorder.RAISED, or EtchedBorder.LOWERED
type
)

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

public static Border

Returns:

the Border object
createEtchedBorder
(int
one of EtchedBorder.RAISED, or EtchedBorder.LOWERED
type
,
Color
a Color object for the border highlights
highlight
,
Color
a Color object for the border shadows
shadow
)

Creates a border with an "etched" look using the specified highlighting and shading colors.

public static Border

Returns:

the Border object
createLineBorder
(Color
a Color to use for the line
color
)

Creates a line border with the specified color.

public static Border

Returns:

the Border object
createLineBorder
(Color
a Color to use for the line
color
,
int
an integer specifying the width in pixels
thickness
)

Creates a line border with the specified color and width.

public static Border

Returns:

the Border object
createLineBorder
(Color
the color of the border
color
,
int
the thickness of the border
thickness
,
boolean
whether or not border corners should be round
rounded
)

Creates a line border with the specified color, thickness, and corner shape.

public static Border

Returns:

the Border object
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.

public static Border

Returns:

the Border object
createLoweredSoftBevelBorder
()

Creates a beveled border with a lowered edge and softened corners, using brighter shades of the component's current background color for highlighting, and darker shading for shadows.

public static MatteBorder

Returns:

the MatteBorder object
createMatteBorder
(int
an integer specifying the width of the top, in pixels
top
,
int
an integer specifying the width of the left side, in pixels
left
,
int
an integer specifying the width of the right side, in pixels
bottom
,
int
an integer specifying the width of the bottom, in pixels
right
,
Color
a Color to use for the border
color
)

Creates a matte-look border using a solid color.

public static MatteBorder

Returns:

the MatteBorder object
createMatteBorder
(int
an integer specifying the width of the top, in pixels
top
,
int
an integer specifying the width of the left side, in pixels
left
,
int
an integer specifying the width of the right side, in pixels
bottom
,
int
an integer specifying the width of the bottom, in pixels
right
,
Icon
the Icon object used for the border tiles
tileIcon
)

Creates a matte-look border that consists of multiple tiles of a specified icon.

public static Border

Returns:

the Border object
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.

public static Border

Returns:

the Border object
createRaisedSoftBevelBorder
()

Creates a beveled border with a raised edge and softened corners, using brighter shades of the component's current background color for highlighting, and darker shading for shadows.

pack-priv static Border
public static Border

Returns:

the Border object or null if the specified type is not valid
createSoftBevelBorder
(int
a type of a bevel
type
)

Creates a beveled border of the specified type with softened corners, using brighter shades of the component's current background color for highlighting, and darker shading for shadows.

public static Border

Returns:

the Border object
createSoftBevelBorder
(int
a type of a bevel
type
,
Color
a basic color of the highlight area
highlight
,
Color
a basic color of the shadow area
shadow
)

Creates a beveled border of the specified type with softened corners, using the specified highlighting and shadowing.

public static Border

Returns:

the Border object
createSoftBevelBorder
(int
a type of a bevel
type
,
Color
a color of the outer edge of the highlight area
highlightOuter
,
Color
a color of the inner edge of the highlight area
highlightInner
,
Color
a color of the outer edge of the shadow area
shadowOuter
,
Color
a color of the inner edge of the shadow area
shadowInner
)

Creates a beveled border of the specified type with softened corners, using the specified colors for the inner and outer edges of the highlight and the shadow areas.

public static Border

Returns:

the Border object
createStrokeBorder
(BasicStroke
the BasicStroke object used to stroke a shape
stroke
)

Creates a border of the specified stroke.

public static Border

Returns:

the Border object
createStrokeBorder
(BasicStroke
the BasicStroke object used to stroke a shape
stroke
,
Paint
the Paint object used to generate a color
paint
)

Creates a border of the specified stroke and paint.

public static TitledBorder

Returns:

the TitledBorder object
createTitledBorder
(String
a String containing the text of the title
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 (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

public static TitledBorder

Returns:

the TitledBorder object
createTitledBorder
(Border
the Border object to add the title to; if null the Border is determined by the current look and feel.
border
)

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

public static TitledBorder

Returns:

the TitledBorder object
createTitledBorder
(Border
the Border object to add the title to
border
,
String
a String containing the text of the title
title
)

Adds a title to an existing border, with default positioning (determined by the current look and feel), default justification (leading) and the default font and text color (determined by the current look and feel).

public static TitledBorder

Returns:

the TitledBorder object
createTitledBorder
(Border
the Border object to add the title to
border
,
String
a String containing the text of the title
title
,
int
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)
titleJustification
,
int
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 (the title position is determined by the current look and feel)
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).

public static TitledBorder

Returns:

the TitledBorder object
createTitledBorder
(Border
the Border object to add the title to
border
,
String
a String containing the text of the title
title
,
int
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)
titleJustification
,
int
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 (the title position is determined by the current look and feel)
titlePosition
,
Font
a Font object specifying the title 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).

public static TitledBorder

Returns:

the TitledBorder object
createTitledBorder
(Border
the Border object to add the title to
border
,
String
a String containing the text of the title
title
,
int
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)
titleJustification
,
int
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 (the title position is determined by the current look and feel)
titlePosition
,
Font
a Font object specifying the title font
titleFont
,
Color
a Color object specifying the title color
titleColor
)

Adds a title to an existing border, with the specified positioning, font and color.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

emptyBorderback to summary
pack-priv static final Border emptyBorder
sharedDashedBorderback to summary
private static Border sharedDashedBorder

/ DashedBorder ////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

sharedEtchedBorderback to summary
pack-priv static final Border sharedEtchedBorder
sharedLoweredBevelback to summary
pack-priv static final Border sharedLoweredBevel
sharedRaisedBevelback to summary
pack-priv static final Border sharedRaisedBevel

/ BevelBorder ///////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////

sharedRaisedEtchedBorderback to summary
private static Border sharedRaisedEtchedBorder
sharedSoftLoweredBevelback to summary
private static Border sharedSoftLoweredBevel
sharedSoftRaisedBevelback to summary
private static Border sharedSoftRaisedBevel

/ SoftBevelBorder /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

Constructor Detail

BorderFactoryback to summary
private BorderFactory()

Don't let anyone instantiate this class

Method Detail

createBevelBorderback to summary
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.)

Parameters
type:int

an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED

Returns:Border

the Border object

createBevelBorderback to summary
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.

Parameters
type:int

an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED

highlight:Color

a Color object for highlights

shadow:Color

a Color object for shadows

Returns:Border

the Border object

createBevelBorderback to summary
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.

Parameters
type:int

an integer specifying either BevelBorder.LOWERED or BevelBorder.RAISED

highlightOuter:Color

a Color object for the outer edge of the highlight area

highlightInner:Color

a Color object for the inner edge of the highlight area

shadowOuter:Color

a Color object for the outer edge of the shadow area

shadowInner:Color

a Color object for the inner edge of the shadow area

Returns:Border

the Border object

createCompoundBorderback to summary
public static CompoundBorder createCompoundBorder()

Creates a compound border with a null inside edge and a null outside edge.

Returns:CompoundBorder

the CompoundBorder object

createCompoundBorderback to summary
public static CompoundBorder createCompoundBorder(Border outsideBorder, Border insideBorder)

Creates a compound border specifying the border objects to use for the outside and inside edges.

Parameters
outsideBorder:Border

a Border object for the outer edge of the compound border

insideBorder:Border

a Border object for the inner edge of the compound border

Returns:CompoundBorder

the CompoundBorder object

createDashedBorderback to summary
public static Border createDashedBorder(Paint paint)

Creates a dashed border of the specified paint. If the specified paint is null, the component's foreground color will be used to render the border. The width of a dash line is equal to 1. The relative length of a dash line and the relative spacing between dash lines are equal to 1. A dash line is not rounded.

Parameters
paint:Paint

the Paint object used to generate a color

Returns:Border

the Border object

Since
1.7
createDashedBorderback to summary
public static Border createDashedBorder(Paint paint, float length, float spacing)

Creates a dashed border of the specified paint, relative length, and relative spacing. If the specified paint is null, the component's foreground color will be used to render the border. The width of a dash line is equal to 1. A dash line is not rounded.

Parameters
paint:Paint

the Paint object used to generate a color

length:float

the relative length of a dash line

spacing:float

the relative spacing between dash lines

Returns:Border

the Border object

Exceptions
IllegalArgumentException:
if the specified length is less than 1, or if the specified spacing is less than 0
Since
1.7
createDashedBorderback to summary
public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded)

Creates a dashed border of the specified paint, thickness, line shape, relative length, and relative spacing. If the specified paint is null, the component's foreground color will be used to render the border.

Parameters
paint:Paint

the Paint object used to generate a color

thickness:float

the width of a dash line

length:float

the relative length of a dash line

spacing:float

the relative spacing between dash lines

rounded:boolean

whether or not line ends should be round

Returns:Border

the Border object

Exceptions
IllegalArgumentException:
if the specified thickness is less than 1, or if the specified length is less than 1, or if the specified spacing is less than 0
Since
1.7
createEmptyBorderback to summary
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.)

Returns:Border

the Border object

createEmptyBorderback to summary
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.

Parameters
top:int

an integer specifying the width of the top, in pixels

left:int

an integer specifying the width of the left side, in pixels

bottom:int

an integer specifying the width of the bottom, in pixels

right:int

an integer specifying the width of the right side, in pixels

Returns:Border

the Border object

createEtchedBorderback to summary
public static Border createEtchedBorder()

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Returns:Border

the Border object

createEtchedBorderback to summary
public static Border createEtchedBorder(Color highlight, Color shadow)

Creates a border with an "etched" look using the specified highlighting and shading colors.

Parameters
highlight:Color

a Color object for the border highlights

shadow:Color

a Color object for the border shadows

Returns:Border

the Border object

createEtchedBorderback to summary
public static Border createEtchedBorder(int type)

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Parameters
type:int

one of EtchedBorder.RAISED, or EtchedBorder.LOWERED

Returns:Border

the Border object

Exceptions
IllegalArgumentException:
if type is not either EtchedBorder.RAISED or EtchedBorder.LOWERED
Since
1.3
createEtchedBorderback to summary
public static Border createEtchedBorder(int type, Color highlight, Color shadow)

Creates a border with an "etched" look using the specified highlighting and shading colors.

Parameters
type:int

one of EtchedBorder.RAISED, or EtchedBorder.LOWERED

highlight:Color

a Color object for the border highlights

shadow:Color

a Color object for the border shadows

Returns:Border

the Border object

Since
1.3
createLineBorderback to summary
public static Border createLineBorder(Color color)

Creates a line border with the specified color.

Parameters
color:Color

a Color to use for the line

Returns:Border

the Border object

createLineBorderback to summary
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).

Parameters
color:Color

a Color to use for the line

thickness:int

an integer specifying the width in pixels

Returns:Border

the Border object

createLineBorderback to summary
public static Border createLineBorder(Color color, int thickness, boolean rounded)

Creates a line border with the specified color, thickness, and corner shape.

Parameters
color:Color

the color of the border

thickness:int

the thickness of the border

rounded:boolean

whether or not border corners should be round

Returns:Border

the Border object

Since
1.7
See Also
LineBorder#LineBorder(Color, int, boolean)
createLoweredBevelBorderback to summary
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.)

Returns:Border

the Border object

createLoweredSoftBevelBorderback to summary
public static Border createLoweredSoftBevelBorder()

Creates a beveled border with a lowered edge and softened corners, 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.

Returns:Border

the Border object

Since
1.7
createMatteBorderback to summary
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.)

Parameters
top:int

an integer specifying the width of the top, in pixels

left:int

an integer specifying the width of the left side, in pixels

bottom:int

an integer specifying the width of the right side, in pixels

right:int

an integer specifying the width of the bottom, in pixels

color:Color

a Color to use for the border

Returns:MatteBorder

the MatteBorder object

createMatteBorderback to summary
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.

Parameters
top:int

an integer specifying the width of the top, in pixels

left:int

an integer specifying the width of the left side, in pixels

bottom:int

an integer specifying the width of the right side, in pixels

right:int

an integer specifying the width of the bottom, in pixels

tileIcon:Icon

the Icon object used for the border tiles

Returns:MatteBorder

the MatteBorder object

createRaisedBevelBorderback to summary
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.)

Returns:Border

the Border object

createRaisedSoftBevelBorderback to summary
public static Border createRaisedSoftBevelBorder()

Creates a beveled border with a raised edge and softened corners, 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.

Returns:Border

the Border object

Since
1.7
createSharedBevelback to summary
pack-priv static Border createSharedBevel(int type)
createSoftBevelBorderback to summary
public static Border createSoftBevelBorder(int type)

Creates a beveled border of the specified type with softened corners, using brighter shades of the component's current background color for highlighting, and darker shading for shadows. The type is either BevelBorder#RAISED or BevelBorder#LOWERED.

Parameters
type:int

a type of a bevel

Returns:Border

the Border object or null if the specified type is not valid

Since
1.7
See Also
BevelBorder#BevelBorder(int)
createSoftBevelBorderback to summary
public static Border createSoftBevelBorder(int type, Color highlight, Color shadow)

Creates a beveled border of the specified type with softened corners, using the specified highlighting and shadowing. The type is either BevelBorder#RAISED or BevelBorder#LOWERED. The outer edge of the highlight area uses a brighter shade of the highlight color. The inner edge of the shadow area uses a brighter shade of the shadow color.

Parameters
type:int

a type of a bevel

highlight:Color

a basic color of the highlight area

shadow:Color

a basic color of the shadow area

Returns:Border

the Border object

Since
1.7
See Also
BevelBorder#BevelBorder(int, Color, Color)
createSoftBevelBorderback to summary
public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner)

Creates a beveled border of the specified type with softened corners, using the specified colors for the inner and outer edges of the highlight and the shadow areas. The type is either BevelBorder#RAISED or BevelBorder#LOWERED.

Note

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

Parameters
type:int

a type of a bevel

highlightOuter:Color

a color of the outer edge of the highlight area

highlightInner:Color

a color of the inner edge of the highlight area

shadowOuter:Color

a color of the outer edge of the shadow area

shadowInner:Color

a color of the inner edge of the shadow area

Returns:Border

the Border object

Since
1.7
See Also
BevelBorder#BevelBorder(int, Color, Color, Color, Color)
createStrokeBorderback to summary
public static Border createStrokeBorder(BasicStroke stroke)

Creates a border of the specified stroke. The component's foreground color will be used to render the border.

Parameters
stroke:BasicStroke

the BasicStroke object used to stroke a shape

Returns:Border

the Border object

Exceptions
NullPointerException:
if the specified stroke is null
Since
1.7
createStrokeBorderback to summary
public static Border createStrokeBorder(BasicStroke stroke, Paint paint)

Creates a border of the specified stroke and paint. If the specified paint is null, the component's foreground color will be used to render the border.

Parameters
stroke:BasicStroke

the BasicStroke object used to stroke a shape

paint:Paint

the Paint object used to generate a color

Returns:Border

the Border object

Exceptions
NullPointerException:
if the specified stroke is null
Since
1.7
createTitledBorderback to summary
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 (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Parameters
title:String

a String containing the text of the title

Returns:TitledBorder

the TitledBorder object

createTitledBorderback to summary
public static TitledBorder createTitledBorder(Border border)

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Parameters
border:Border

the Border object to add the title to; if null the Border is determined by the current look and feel.

Returns:TitledBorder

the TitledBorder object

createTitledBorderback to summary
public static TitledBorder createTitledBorder(Border border, String title)

Adds a title to an existing border, with default positioning (determined by the current look and feel), default justification (leading) and the default font and text color (determined by the current look and feel).

Parameters
border:Border

the Border object to add the title to

title:String

a String containing the text of the title

Returns:TitledBorder

the TitledBorder object

createTitledBorderback to summary
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).

Parameters
border:Border

the Border object to add the title to

title:String

a String containing the text of the title

titleJustification:int

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)
titlePosition:int

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 (the title position is determined by the current look and feel)
Returns:TitledBorder

the TitledBorder object

createTitledBorderback to summary
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).

Parameters
border:Border

the Border object to add the title to

title:String

a String containing the text of the title

titleJustification:int

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)
titlePosition:int

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 (the title position is determined by the current look and feel)
titleFont:Font

a Font object specifying the title font

Returns:TitledBorder

the TitledBorder object

createTitledBorderback to summary
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.

Parameters
border:Border

the Border object to add the title to

title:String

a String containing the text of the title

titleJustification:int

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)
titlePosition:int

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 (the title position is determined by the current look and feel)
titleFont:Font

a Font object specifying the title font

titleColor:Color

a Color object specifying the title color

Returns:TitledBorder

the TitledBorder object