Top Description Fields Constructors Methods
javax.swing.border

public Class StrokeBorder

extends AbstractBorder
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.awt.BasicStroke, .Component, .Graphics, .Graphics2D, .Insets, .Paint, .RenderingHints, java.awt.geom.Rectangle2D, java.beans.ConstructorProperties

A class which implements a border of an arbitrary stroke.

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
Sergey A. Malenkov
Since
1.7

Field Summary

Modifier and TypeField and Description
private final Paint
private final BasicStroke

Constructor Summary

AccessConstructor and Description
public
StrokeBorder(BasicStroke
the BasicStroke object used to stroke a shape
stroke
)

Creates a border of the specified stroke.

public
StrokeBorder(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.

Method Summary

Modifier and TypeMethod and Description
public Insets

Returns:

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

Overrides javax.swing.border.AbstractBorder.getBorderInsets.

Reinitializes the insets parameter with this border's current insets.
public Paint

Returns:

the Paint object or null if the paint parameter is not set
getPaint
()

Returns the Paint object used to generate a color during the border rendering.

public BasicStroke

Returns:

the BasicStroke object
getStroke
()

Returns the BasicStroke object used to stroke a shape during the border rendering.

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.
Inherited from javax.swing.border.AbstractBorder:
getBaselinegetBaselineResizeBehaviorgetBorderInsetsgetInteriorRectanglegetInteriorRectangleisBorderOpaqueisLeftToRight

Field Detail

paintback to summary
private final Paint paint
strokeback to summary
private final BasicStroke stroke

Constructor Detail

StrokeBorderback to summary
public StrokeBorder(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

Exceptions
NullPointerException:
if the specified stroke is null
StrokeBorderback to summary
public StrokeBorder(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

Annotations
@ConstructorProperties:stroke, paint
Exceptions
NullPointerException:
if the specified stroke is null

Method Detail

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

Overrides javax.swing.border.AbstractBorder.getBorderInsets.

Reinitializes the insets parameter with this border's current insets. Every inset is the smallest (closest to negative infinity) integer value that is greater than or equal to the line width of the stroke that is used to paint the border.

Parameters
c:Component

the component for which this border insets value applies

insets:Insets

the Insets object to be reinitialized

Returns:Insets

the reinitialized insets parameter

Annotations
@Override
Exceptions
NullPointerException:
if the specified insets is null
See Also
Math#ceil
getPaintback to summary
public Paint getPaint()

Returns the Paint object used to generate a color during the border rendering.

Returns:Paint

the Paint object or null if the paint parameter is not set

getStrokeback to summary
public BasicStroke getStroke()

Returns the BasicStroke object used to stroke a shape during the border rendering.

Returns:BasicStroke

the BasicStroke object

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. If the border was not specified with a Paint object, the component's foreground color will be used to render the border. If the component's foreground color is not available, the default color of the Graphics object will be used.

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

Annotations
@Override
Exceptions
NullPointerException:
if the specified g is null