APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.border

public Class EtchedBorder

extends AbstractBorder
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.BorderUIResource.EtchedBorderUIResource
Annotations
@SuppressWarnings:serial
Imports
java.awt.BasicStroke, .Graphics, .Graphics2D, .Insets, .Color, .Component, java.beans.ConstructorProperties, com.sun.java.swing.SwingUtilities3

A class which implements a simple etched border which can either be etched-in or etched-out. If no highlight/shadow colors are initialized when the border is created, then these colors will be dynamically derived from the background color of the component argument passed into the paintBorder() method.

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.

Authors
David Kloba, Amy Fowler

Field Summary

Modifier and TypeField and Description
protected int
etchType

The type of etch to be drawn by the border.

protected Color
highlight

The color to use for the etched highlight.

public static final int
LOWERED

Lowered etched type.

public static final int
RAISED

Raised etched type.

protected Color
shadow

The color to use for the etched shadow.

Constructor Summary

AccessConstructor and Description
public
EtchedBorder()

Creates a lowered etched border whose colors will be derived from the background color of the component passed into the paintBorder method.

public
EtchedBorder(int
the type of etch to be drawn by the border
etchType
)

Creates an etched border with the specified etch-type whose colors will be derived from the background color of the component passed into the paintBorder method.

public
EtchedBorder(Color
the color to use for the etched highlight
highlight
,
Color
the color to use for the etched shadow
shadow
)

Creates a lowered etched border with the specified highlight and shadow colors.

public
EtchedBorder(int
the type of etch to be drawn by the border
etchType
,
Color
the color to use for the etched highlight
highlight
,
Color
the color to use for the etched shadow
shadow
)

Creates an etched border with the specified etch-type, highlight and shadow colors.

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 int

Returns:

the etched border type, either RAISED or LOWERED
getEtchType
()

Returns which etch-type is set on the etched border.

public Color

Returns:

the highlight Color of this EtchedBorder
getHighlightColor
(Component
the component for which the highlight may be derived
c
)

Returns the highlight color of the etched border when rendered on the specified component.

public Color

Returns:

the highlight Color of this EtchedBorder or null if none was specified
getHighlightColor
()

Returns the highlight color of the etched border.

public Color

Returns:

the shadow Color of this EtchedBorder
getShadowColor
(Component
the component for which the shadow may be derived
c
)

Returns the shadow color of the etched border when rendered on the specified component.

public Color

Returns:

the shadow Color of this EtchedBorder or null if none was specified
getShadowColor
()

Returns the shadow color of the etched border.

public boolean

Returns:

true
isBorderOpaque
()

Overrides javax.swing.border.AbstractBorder.isBorderOpaque.

Implements javax.swing.border.Border.isBorderOpaque.

Returns whether or not the 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 border for the specified component with the specified position and size.

private void
paintBorderHighlight(Graphics g, Color c, int w, int h, int stkWidth)

private void
paintBorderShadow(Graphics g, Color c, int w, int h, int stkWidth)

private void
paintUnscaledBorder(Component c, Graphics g, int w, int h, double scaleFactor)

Inherited from javax.swing.border.AbstractBorder:
getBaselinegetBaselineResizeBehaviorgetBorderInsetsgetInteriorRectanglegetInteriorRectangleisLeftToRight

Field Detail

etchTypeback to summary
protected int etchType

The type of etch to be drawn by the border.

highlightback to summary
protected Color highlight

The color to use for the etched highlight.

LOWEREDback to summary
public static final int LOWERED

Lowered etched type.

RAISEDback to summary
public static final int RAISED

Raised etched type.

shadowback to summary
protected Color shadow

The color to use for the etched shadow.

Constructor Detail

EtchedBorderback to summary
public EtchedBorder()

Creates a lowered etched border whose colors will be derived from the background color of the component passed into the paintBorder method.

EtchedBorderback to summary
public EtchedBorder(int etchType)

Creates an etched border with the specified etch-type whose colors will be derived from the background color of the component passed into the paintBorder method.

Parameters
etchType:int

the type of etch to be drawn by the border

EtchedBorderback to summary
public EtchedBorder(Color highlight, Color shadow)

Creates a lowered etched border with the specified highlight and shadow colors.

Parameters
highlight:Color

the color to use for the etched highlight

shadow:Color

the color to use for the etched shadow

EtchedBorderback to summary
public EtchedBorder(int etchType, Color highlight, Color shadow)

Creates an etched border with the specified etch-type, highlight and shadow colors.

Parameters
etchType:int

the type of etch to be drawn by the border

highlight:Color

the color to use for the etched highlight

shadow:Color

the color to use for the etched shadow

Annotations
@ConstructorProperties:etchType, highlightColor, shadowColor

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

Exceptions
NullPointerException:
if the specified insets is null
getEtchTypeback to summary
public int getEtchType()

Returns which etch-type is set on the etched border.

Returns:int

the etched border type, either RAISED or LOWERED

getHighlightColorback to summary
public Color getHighlightColor(Component c)

Returns the highlight color of the etched border when rendered on the specified component. If no highlight color was specified at instantiation, the highlight color is derived from the specified component's background color.

Parameters
c:Component

the component for which the highlight may be derived

Returns:Color

the highlight Color of this EtchedBorder

Since
1.3
getHighlightColorback to summary
public Color getHighlightColor()

Returns the highlight color of the etched border. Will return null if no highlight color was specified at instantiation.

Returns:Color

the highlight Color of this EtchedBorder or null if none was specified

Since
1.3
getShadowColorback to summary
public Color getShadowColor(Component c)

Returns the shadow color of the etched border when rendered on the specified component. If no shadow color was specified at instantiation, the shadow color is derived from the specified component's background color.

Parameters
c:Component

the component for which the shadow may be derived

Returns:Color

the shadow Color of this EtchedBorder

Since
1.3
getShadowColorback to summary
public Color getShadowColor()

Returns the shadow color of the etched border. Will return null if no shadow color was specified at instantiation.

Returns:Color

the shadow Color of this EtchedBorder or null if none was specified

Since
1.3
isBorderOpaqueback to summary
public boolean isBorderOpaque()

Overrides javax.swing.border.AbstractBorder.isBorderOpaque.

Implements javax.swing.border.Border.isBorderOpaque.

Returns whether or not the border is opaque. This implementation returns true.

Returns:boolean

true

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 border for the specified component with the specified position and size.

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

paintBorderHighlightback to summary
private void paintBorderHighlight(Graphics g, Color c, int w, int h, int stkWidth)
paintBorderShadowback to summary
private void paintBorderShadow(Graphics g, Color c, int w, int h, int stkWidth)
paintUnscaledBorderback to summary
private void paintUnscaledBorder(Component c, Graphics g, int w, int h, double scaleFactor)