javax.swing.border
Class AbstractBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
All Implemented Interfaces:
Serializable, Border
Direct Known Subclasses:
BasicBorders.ButtonBorder, BasicBorders.FieldBorder, BasicBorders.MarginBorder, BasicBorders.MenuBarBorder, BevelBorder, CompoundBorder, EmptyBorder, EtchedBorder, LineBorder, MetalBorders.ButtonBorder, MetalBorders.Flush3DBorder, MetalBorders.InternalFrameBorder, MetalBorders.MenuBarBorder, MetalBorders.MenuItemBorder, MetalBorders.OptionDialogBorder, MetalBorders.PaletteBorder, MetalBorders.PopupMenuBorder, MetalBorders.ScrollPaneBorder, MetalBorders.TableHeaderBorder, MetalBorders.ToolBarBorder, TitledBorder

public abstract class AbstractBorder
extends Object
implements Border, Serializable

An invisible zero-width border, serving as a base class for implementing more interesting borders.

See Also:
Serialized Form

Constructor Summary
AbstractBorder()
          Constructs a new AbstractBorder.
 
Method Summary
 Insets getBorderInsets(Component c)
          Returns the insets required for drawing this border around the specified component.
 Insets getBorderInsets(Component c, Insets insets)
          Returns the insets required for drawing this border around the specified component.
static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height)
          Returns a rectangle that covers the specified area minus the insets required to draw the specified border (if the border is null, zero insets are assumed).
 Rectangle getInteriorRectangle(Component c, int x, int y, int width, int height)
          Returns a rectangle that covers the specified area minus the insets required to draw this border.
 boolean isBorderOpaque()
          Determines whether or not this border is opaque.
 void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
          Performs nothing, because the default implementation provided by this class is an invisible, zero-width border.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBorder

public AbstractBorder()
Constructs a new AbstractBorder.

Method Detail

paintBorder

public void paintBorder(Component c,
                        Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Performs nothing, because the default implementation provided by this class is an invisible, zero-width border. Subclasses will likely want to override this method, but they are not required to do so.

Specified by:
paintBorder in interface Border
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)
Returns the insets required for drawing this border around the specified component.

Specified by:
getBorderInsets in interface Border
Parameters:
c - the component that the border applies to (ignored here, subclasses may use it).
Returns:
an Insets object whose left, right, top and bottom fields indicate the width of the border at the respective edge, which is zero for the default implementation provided by AbstractButton.
See Also:
getBorderInsets(java.awt.Component, java.awt.Insets)

getBorderInsets

public Insets getBorderInsets(Component c,
                              Insets insets)
Returns the insets required for drawing this border around the specified component. The default implementation provided here sets the left, right, top and bottom fields of the passed insets parameter to zero.

Parameters:
c - the component that the border applies to (ignored here, subclasses may use it).
insets - an instance that will be overwritten and returned as the result (null not permitted).
Returns:
The border insets (the same object that was passed as the insets argument).
Throws:
NullPointerException - if insets is null.
See Also:
getBorderInsets(Component)

isBorderOpaque

public boolean isBorderOpaque()
Determines whether or not this border is opaque. An opaque border fills every pixel in its area when painting. Partially translucent borders must return false, or ugly artifacts can appear on screen. The default implementation provided here always returns false.

Specified by:
isBorderOpaque in interface Border
Returns:
false.

getInteriorRectangle

public Rectangle getInteriorRectangle(Component c,
                                      int x,
                                      int y,
                                      int width,
                                      int height)
Returns a rectangle that covers the specified area minus the insets required to draw this border. Components that wish to determine an area into which they can safely draw without intersecting with a border might want to use this helper method.

Parameters:
c - the component in the center of this border.
x - the horizontal position of the border.
y - the vertical position of the border.
width - the width of the available area for the border.
height - the height of the available area for the border.
Returns:
The interior rectangle.

getInteriorRectangle

public static Rectangle getInteriorRectangle(Component c,
                                             Border b,
                                             int x,
                                             int y,
                                             int width,
                                             int height)
Returns a rectangle that covers the specified area minus the insets required to draw the specified border (if the border is null, zero insets are assumed). Components that wish to determine an area into which they can safely draw without intersecting with a border might want to use this helper method.

Parameters:
c - the component in the center of this border.
b - the border (null permitted).
x - the horizontal position of the border.
y - the vertical position of the border.
width - the width of the available area for the border.
height - the height of the available area for the border.
Returns:
The interior rectangle.