org.tentackle.ui
Class EnhancedLineBorder

java.lang.Object
  extended by javax.swing.border.AbstractBorder
      extended by javax.swing.border.LineBorder
          extended by org.tentackle.ui.EnhancedLineBorder
All Implemented Interfaces:
Serializable, Border

public class EnhancedLineBorder
extends LineBorder

A LineBorder with the ability to enable/disable each of its four sides.

Author:
harald
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.border.LineBorder
lineColor, roundedCorners, thickness
 
Constructor Summary
EnhancedLineBorder()
          Creates a line border with black color, a thickness of 1 and all four sides enabled.
EnhancedLineBorder(boolean topEnabled, boolean leftEnabled, boolean bottomEnabled, boolean rightEnabled)
          Creates a line border with the black color, thickness 1 and all four sides enabled separately.
EnhancedLineBorder(Color color)
          Creates a line border with the specified color, a thickness of 1 and all four sides enabled.
EnhancedLineBorder(Color color, int thickness)
          Creates a line border with the specified color, thickness and all four sides enabled.
EnhancedLineBorder(Color color, int thickness, boolean topEnabled, boolean leftEnabled, boolean bottomEnabled, boolean rightEnabled)
          Creates a line border with the specified color, thickness and all four sides enabled separately.
 
Method Summary
 Insets getBorderInsets(Component c)
          Returns the insets of the border.
 Insets getBorderInsets(Component c, Insets insets)
          Reinitialize the insets parameter with this Border's current Insets.
 Color getLineColor()
          Returns the color of the border.
 void getLineColor(Color lineColor)
          Sets the color of the border.
 int getThickness()
          Returns the thickness of the border.
 boolean isBottomEnabled()
          Returns whether bottom border is enabled.
 boolean isLeftEnabled()
          Returns whether left border is enabled.
 boolean isRightEnabled()
          Returns whether right border is enabled.
 boolean isTopEnabled()
          Returns whether top border is enabled.
 void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
          Paints the border for the specified component with the specified position and size.
 void setBottomEnabled(boolean enabled)
          Enables the bottom border.
 void setLeftEnabled(boolean enabled)
          Enables the left border.
 void setRightEnabled(boolean enabled)
          Enables the right border.
 void setThickness(int thickness)
          Sets the thickness of the border.
 void setTopEnabled(boolean enabled)
          Enables the top border.
 
Methods inherited from class javax.swing.border.LineBorder
createBlackLineBorder, createGrayLineBorder, getRoundedCorners, isBorderOpaque
 
Methods inherited from class javax.swing.border.AbstractBorder
getBaseline, getBaselineResizeBehavior, getInteriorRectangle, getInteriorRectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnhancedLineBorder

public EnhancedLineBorder(Color color,
                          int thickness,
                          boolean topEnabled,
                          boolean leftEnabled,
                          boolean bottomEnabled,
                          boolean rightEnabled)
Creates a line border with the specified color, thickness and all four sides enabled separately.

Parameters:
color - the color of the border
thickness - the thickness of the border
topEnabled - true if top border is drawn
leftEnabled - true if left border is drawn
bottomEnabled - true if bottom border is drawn
rightEnabled - true if right border is drawn

EnhancedLineBorder

public EnhancedLineBorder(boolean topEnabled,
                          boolean leftEnabled,
                          boolean bottomEnabled,
                          boolean rightEnabled)
Creates a line border with the black color, thickness 1 and all four sides enabled separately.

Parameters:
topEnabled - true if top border is drawn
leftEnabled - true if left border is drawn
bottomEnabled - true if bottom border is drawn
rightEnabled - true if right border is drawn

EnhancedLineBorder

public EnhancedLineBorder(Color color,
                          int thickness)
Creates a line border with the specified color, thickness and all four sides enabled.

Parameters:
color - the color of the border
thickness - the thickness of the border

EnhancedLineBorder

public EnhancedLineBorder(Color color)
Creates a line border with the specified color, a thickness of 1 and all four sides enabled.

Parameters:
color - the color for the border

EnhancedLineBorder

public EnhancedLineBorder()
Creates a line border with black color, a thickness of 1 and all four sides enabled.

Method Detail

setTopEnabled

public void setTopEnabled(boolean enabled)
Enables the top border.

Parameters:
enabled - true if draw top border

isTopEnabled

public boolean isTopEnabled()
Returns whether top border is enabled.

Returns:
true if top border is drawn

setBottomEnabled

public void setBottomEnabled(boolean enabled)
Enables the bottom border.

Parameters:
enabled - true if draw bottom border

isBottomEnabled

public boolean isBottomEnabled()
Returns whether bottom border is enabled.

Returns:
true if bottom border is drawn

setLeftEnabled

public void setLeftEnabled(boolean enabled)
Enables the left border.

Parameters:
enabled - true if draw left border

isLeftEnabled

public boolean isLeftEnabled()
Returns whether left border is enabled.

Returns:
true if left border is drawn

setRightEnabled

public void setRightEnabled(boolean enabled)
Enables the right border.

Parameters:
enabled - true if draw right border

isRightEnabled

public boolean isRightEnabled()
Returns whether right border is enabled.

Returns:
true if right border is drawn

getLineColor

public void getLineColor(Color lineColor)
Sets the color of the border.

Parameters:
lineColor - the border color

getLineColor

public Color getLineColor()
Returns the color of the border.

Overrides:
getLineColor in class LineBorder
Returns:
the border color

setThickness

public void setThickness(int thickness)
Sets the thickness of the border.

Parameters:
thickness - the thickness

getThickness

public int getThickness()
Returns the thickness of the border.

Overrides:
getThickness in class LineBorder
Returns:
the thickness

paintBorder

public void paintBorder(Component c,
                        Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Paints the border for the specified component with the specified position and size.

Specified by:
paintBorder in interface Border
Overrides:
paintBorder in class LineBorder
Parameters:
c - the component for which this border is being painted
g - the paint graphics
x - the x position of the painted border
y - the y position of the painted border
width - the width of the painted border
height - the height of the painted border

getBorderInsets

public Insets getBorderInsets(Component c)
Returns the insets of the border.

Specified by:
getBorderInsets in interface Border
Overrides:
getBorderInsets in class LineBorder
Parameters:
c - the component for which this border insets value applies
Returns:
the new Insets object initialized to 0

getBorderInsets

public Insets getBorderInsets(Component c,
                              Insets insets)
Reinitialize the insets parameter with this Border's current Insets.

Overrides:
getBorderInsets in class LineBorder
Parameters:
c - the component for which this border insets value applies
insets - the object to be reinitialized
Returns:
the insets object


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de