APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.border

public Class LineBorder

extends AbstractBorder
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.BorderUIResource.LineBorderUIResource, javax.swing.text.html.CommentView.CommentBorder
Annotations
@SuppressWarnings:serial
Imports
java.awt.Graphics, .Insets, .Color, .Component, .Graphics2D, .Shape, java.awt.geom.Path2D, .Rectangle2D, .RoundRectangle2D, java.beans.ConstructorProperties, com.sun.java.swing.SwingUtilities3

A class which implements a line border of arbitrary thickness and of a single color.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Author
David Kloba

Field Summary

Modifier and TypeField and Description
private static Border
private static Border
protected Color
lineColor

Color of the border.

protected boolean
roundedCorners

Whether or not the border has rounded corners.

protected int
thickness

Thickness of the border.

Constructor Summary

AccessConstructor and Description
public
LineBorder(Color
the color for the border
color
)

Creates a line border with the specified color and a thickness = 1.

public
LineBorder(Color
the color of the border
color
,
int
the thickness of the border
thickness
)

Creates a line border with the specified color and thickness.

public
LineBorder(Color
the color of the border
color
,
int
the thickness of the border
thickness
,
boolean
whether or not border corners should be round
roundedCorners
)

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

Method Summary

Modifier and TypeMethod and Description
public static Border

Returns:

a LineBorder with Color.black and thickness of 1
createBlackLineBorder
()

Convenience method for getting the Color.black LineBorder of thickness 1.

public static Border

Returns:

a LineBorder with Color.gray and thickness of 1
createGrayLineBorder
()

Convenience method for getting the Color.gray LineBorder of thickness 1.

public Insets
getBorderInsets(Component
the component for which this border insets value applies
c
,
Insets
the object to be reinitialized
insets
)

Overrides javax.swing.border.AbstractBorder.getBorderInsets.

Reinitialize the insets parameter with this Border's current Insets.

public Color

Returns:

a Color object representing the color of this object
getLineColor
()

Returns the color of the border.

public boolean

Returns:

true if this border should have rounded corners
getRoundedCorners
()

Returns whether this border will be drawn with rounded corners.

public int

Returns:

the thickness of this border
getThickness
()

Returns the thickness of the border.

public boolean

Returns:

true if the border is opaque, false otherwise
isBorderOpaque
()

Overrides javax.swing.border.AbstractBorder.isBorderOpaque.

Implements javax.swing.border.Border.isBorderOpaque.

Returns whether or not the border is opaque.

public void
paintBorder(Component
the component for which this border is being painted
c
,
Graphics
the paint graphics
g
,
int
the x position of the painted border
x
,
int
the y position of the painted border
y
,
int
the width of the painted border
width
,
int
the height of the painted border
height
)

Overrides javax.swing.border.AbstractBorder.paintBorder.

Implements javax.swing.border.Border.paintBorder.

Paints the border for the specified component with the specified position and size.

private void
paintUnscaledBorder(Component c, Graphics g, int w, int h, double scaleFactor)

Inherited from javax.swing.border.AbstractBorder:
getBaselinegetBaselineResizeBehaviorgetBorderInsetsgetInteriorRectanglegetInteriorRectangleisLeftToRight

Field Detail

blackLineback to summary
private static Border blackLine
grayLineback to summary
private static Border grayLine
lineColorback to summary
protected Color lineColor

Color of the border.

roundedCornersback to summary
protected boolean roundedCorners

Whether or not the border has rounded corners.

thicknessback to summary
protected int thickness

Thickness of the border.

Constructor Detail

LineBorderback to summary
public LineBorder(Color color)

Creates a line border with the specified color and a thickness = 1.

Parameters
color:Color

the color for the border

LineBorderback to summary
public LineBorder(Color color, int thickness)

Creates a line border with the specified color and thickness.

Parameters
color:Color

the color of the border

thickness:int

the thickness of the border

LineBorderback to summary
public LineBorder(Color color, int thickness, boolean roundedCorners)

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

roundedCorners:boolean

whether or not border corners should be round

Annotations
@ConstructorProperties:lineColor, thickness, roundedCorners
Since
1.3

Method Detail

createBlackLineBorderback to summary
public static Border createBlackLineBorder()

Convenience method for getting the Color.black LineBorder of thickness 1.

Returns:Border

a LineBorder with Color.black and thickness of 1

createGrayLineBorderback to summary
public static Border createGrayLineBorder()

Convenience method for getting the Color.gray LineBorder of thickness 1.

Returns:Border

a LineBorder with Color.gray and thickness of 1

getBorderInsetsback to summary
public Insets getBorderInsets(Component c, Insets insets)

Overrides javax.swing.border.AbstractBorder.getBorderInsets.

Reinitialize the insets parameter with this Border's current Insets.

Parameters
c:Component

the component for which this border insets value applies

insets:Insets

the object to be reinitialized

Exceptions
NullPointerException:
if the specified insets is null
getLineColorback to summary
public Color getLineColor()

Returns the color of the border.

Returns:Color

a Color object representing the color of this object

getRoundedCornersback to summary
public boolean getRoundedCorners()

Returns whether this border will be drawn with rounded corners.

Returns:boolean

true if this border should have rounded corners

Since
1.3
getThicknessback to summary
public int getThickness()

Returns the thickness of the border.

Returns:int

the thickness of this border

isBorderOpaqueback to summary
public boolean isBorderOpaque()

Overrides javax.swing.border.AbstractBorder.isBorderOpaque.

Implements javax.swing.border.Border.isBorderOpaque.

Returns whether or not the border is opaque.

Returns:boolean

true if the border is opaque, false otherwise

paintBorderback to summary
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)

Overrides javax.swing.border.AbstractBorder.paintBorder.

Implements javax.swing.border.Border.paintBorder.

Paints the border for the specified component with the specified position and size.

Parameters
c:Component

the component for which this border is being painted

g:Graphics

the paint graphics

x:int

the x position of the painted border

y:int

the y position of the painted border

width:int

the width of the painted border

height:int

the height of the painted border

paintUnscaledBorderback to summary
private void paintUnscaledBorder(Component c, Graphics g, int w, int h, double scaleFactor)