javax.swing.border

Class EmptyBorder

public class EmptyBorder extends AbstractBorder

A border for leaving a specifiable number of pixels empty around the enclosed component. An EmptyBorder requires some space on each edge, but does not perform any drawing.

[An illustration of EmptyBorder]

Field Summary
protected intbottom
The number of pixels required at the bottom edge.
protected intleft
The number of pixels required at the left edge.
protected intright
The number of pixels required at the right edge.
protected inttop
The number of pixels required at the top edge.
Constructor Summary
EmptyBorder(int top, int left, int bottom, int right)
Constructs an empty border given the number of pixels required on each side.
EmptyBorder(Insets borderInsets)
Constructs an empty border given the number of pixels required on each side, passed in an Insets object.
Method Summary
InsetsgetBorderInsets(Component c)
Measures the width of this border.
InsetsgetBorderInsets(Component c, Insets insets)
Measures the width of this border, storing the results into a pre-existing Insets object.
InsetsgetBorderInsets()
Measures the width of this border.
booleanisBorderOpaque()
Determines whether this border fills every pixel in its area when painting.
voidpaintBorder(Component c, Graphics g, int x, int y, int width, int height)
Performs nothing because an EmptyBorder does not paint any pixels.

Field Detail

bottom

protected int bottom
The number of pixels required at the bottom edge.

left

protected int left
The number of pixels required at the left edge.

right

protected int right
The number of pixels required at the right edge.

top

protected int top
The number of pixels required at the top edge.

Constructor Detail

EmptyBorder

public EmptyBorder(int top, int left, int bottom, int right)
Constructs an empty border given the number of pixels required on each side.

Parameters: top the number of pixels that the border will need for its top edge. left the number of pixels that the border will need for its left edge. bottom the number of pixels that the border will need for its bottom edge. right the number of pixels that the border will need for its right edge.

EmptyBorder

public EmptyBorder(Insets borderInsets)
Constructs an empty border given the number of pixels required on each side, passed in an Insets object.

Parameters: borderInsets the Insets for the new border.

Method Detail

getBorderInsets

public Insets getBorderInsets(Component c)
Measures the width of this border.

Parameters: c the component whose border is to be measured.

Returns: an Insets object whose left, right, top and bottom fields indicate the width of the border at the respective edge.

See Also: EmptyBorder

getBorderInsets

public Insets getBorderInsets(Component c, Insets insets)
Measures the width of this border, storing the results into a pre-existing Insets object.

Parameters: insets an Insets object for holding the result values. After invoking this method, the left, right, top and bottom fields indicate the width of the border at the respective edge.

Returns: the same object that was passed for insets.

See Also: getBorderInsets

getBorderInsets

public Insets getBorderInsets()
Measures the width of this border.

Returns: an Insets object whose left, right, top and bottom fields indicate the width of the border at the respective edge.

See Also: EmptyBorder

isBorderOpaque

public boolean isBorderOpaque()
Determines whether this border fills every pixel in its area when painting. Since an empty border does not paint any pixels whatsoever, the result is false.

Returns: false.

paintBorder

public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
Performs nothing because an EmptyBorder does not paint any pixels. While the inherited implementation provided by {@link AbstractBorder#paintBorder} is a no-op as well, it is overwritten in order to match the API of the Sun reference implementation.

Parameters: c the component whose border is to be painted. g the graphics for painting. x the horizontal position for painting the border. y the vertical position for painting the border. width the width of the available area for painting the border. height the height of the available area for painting the border.