javax.swing.border
Class EmptyBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
      extended by javax.swing.border.EmptyBorder
All Implemented Interfaces:
Serializable, Border
Direct Known Subclasses:
BorderUIResource.EmptyBorderUIResource, MatteBorder

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]

See Also:
Serialized Form

Field Summary
protected  int bottom
          The number of pixels required at the bottom edge.
protected  int left
          The number of pixels required at the left edge.
protected  int right
          The number of pixels required at the right edge.
protected  int top
          The number of pixels required at the top edge.
 
Constructor Summary
EmptyBorder(Insets borderInsets)
          Constructs an empty border given the number of pixels required on each side, passed in an Insets object.
EmptyBorder(int top, int left, int bottom, int right)
          Constructs an empty border given the number of pixels required on each side.
 
Method Summary
 Insets getBorderInsets()
          Measures the width of this border.
 Insets getBorderInsets(Component c)
          Measures the width of this border.
 Insets getBorderInsets(Component c, Insets insets)
          Measures the width of this border, storing the results into a pre-existing Insets object.
 boolean isBorderOpaque()
          Determines whether this border fills every pixel in its area when painting.
 void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
          Performs nothing because an EmptyBorder does not paint any pixels.
 
Methods inherited from class javax.swing.border.AbstractBorder
getInteriorRectangle, getInteriorRectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.


bottom

protected int bottom
The number of pixels required at the bottom 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

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 AbstractBorder.paintBorder(java.awt.Component, java.awt.Graphics, int, int, int, int) is a no-op as well, it is overwritten in order to match the API of the Sun reference implementation.

Specified by:
paintBorder in interface Border
Overrides:
paintBorder in class AbstractBorder
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.

getBorderInsets

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

Specified by:
getBorderInsets in interface Border
Overrides:
getBorderInsets in class AbstractBorder
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:
getBorderInsets(java.awt.Component, java.awt.Insets)

getBorderInsets

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

Overrides:
getBorderInsets in class AbstractBorder
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.
c - the component that the border applies to (ignored here, subclasses may use it).
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:
getBorderInsets(java.awt.Component, java.awt.Insets)

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.

Specified by:
isBorderOpaque in interface Border
Overrides:
isBorderOpaque in class AbstractBorder
Returns:
false.