Top Description Fields Constructors Methods
javax.swing.border

public Class CompoundBorder

extends AbstractBorder
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.BorderUIResource.CompoundBorderUIResource
Annotations
@SuppressWarnings:serial
Imports
java.awt.Graphics, .Insets, .Component, java.beans.ConstructorProperties

A composite Border class used to compose two Border objects into a single border by nesting an inside Border object within the insets of an outside Border object. For example, this class may be used to add blank margin space to a component with an existing decorative border:
   Border border = comp.getBorder();
   Border margin = new EmptyBorder(10,10,10,10);
   comp.setBorder(new CompoundBorder(border, margin));

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
protected Border
insideBorder

The inside border.

protected Border
outsideBorder

The outside border.

Constructor Summary

AccessConstructor and Description
public
CompoundBorder()

Creates a compound border with null outside and inside borders.

public
CompoundBorder(Border
the outside border
outsideBorder
,
Border
the inside border to be nested
insideBorder
)

Creates a compound border with the specified outside and inside borders.

Method Summary

Modifier and TypeMethod and Description
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 Border

Returns:

the inside Border object
getInsideBorder
()

Returns the inside border object.

public Border

Returns:

the outside Border object
getOutsideBorder
()

Returns the outside border object.

public boolean

Returns:

true if the inside and outside borders are each either null or opaque; or false otherwise
isBorderOpaque
()

Overrides javax.swing.border.AbstractBorder.isBorderOpaque.

Implements javax.swing.border.Border.isBorderOpaque.

Returns whether or not the compound 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 compound border by painting the outside border with the specified position and size and then painting the inside border at the specified position and size offset by the insets of the outside border.
Inherited from javax.swing.border.AbstractBorder:
getBaselinegetBaselineResizeBehaviorgetBorderInsetsgetInteriorRectanglegetInteriorRectangleisLeftToRight

Field Detail

insideBorderback to summary
protected Border insideBorder

The inside border.

outsideBorderback to summary
protected Border outsideBorder

The outside border.

Constructor Detail

CompoundBorderback to summary
public CompoundBorder()

Creates a compound border with null outside and inside borders.

CompoundBorderback to summary
public CompoundBorder(Border outsideBorder, Border insideBorder)

Creates a compound border with the specified outside and inside borders. Either border may be null.

Parameters
outsideBorder:Border

the outside border

insideBorder:Border

the inside border to be nested

Annotations
@ConstructorProperties:outsideBorder, insideBorder

Method Detail

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

Returns:Insets

Doc from javax.swing.border.AbstractBorder.getBorderInsets.

the insets object

Exceptions
NullPointerException:
if the specified insets is null
getInsideBorderback to summary
public Border getInsideBorder()

Returns the inside border object.

Returns:Border

the inside Border object

getOutsideBorderback to summary
public Border getOutsideBorder()

Returns the outside border object.

Returns:Border

the outside Border object

isBorderOpaqueback to summary
public boolean isBorderOpaque()

Overrides javax.swing.border.AbstractBorder.isBorderOpaque.

Implements javax.swing.border.Border.isBorderOpaque.

Returns whether or not the compound border is opaque.

Returns:boolean

true if the inside and outside borders are each either null or opaque; or false otherwise

Annotations
@Override
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 compound border by painting the outside border with the specified position and size and then painting the inside border at the specified position and size offset by the insets of the outside border.

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