javax.swing.border
public class EtchedBorder extends AbstractBorder
Modifier and Type | Field and Description |
---|---|
protected int |
etchType
|
protected Color |
highlight
The highlight color, or
null to indicate that the
color shall be derived from the background of the enclosed
component. |
static int |
LOWERED
Indicates that the border appears as engraved into the
background.
|
static int |
RAISED
Indicates that the border appears as coming out of the
background.
|
protected Color |
shadow
The shadow color, or
null to indicate that the
color shall be derived from the background of the enclosed
component. |
Constructor and Description |
---|
EtchedBorder()
Constructs a lowered EtchedBorder.
|
EtchedBorder(Color highlight,
Color shadow)
Constructs a lowered EtchedBorder, explicitly selecting the
colors that will be used for highlight and shadow.
|
EtchedBorder(int etchType)
Constructs an EtchedBorder with the specified appearance.
|
EtchedBorder(int etchType,
Color highlight,
Color shadow)
Constructs an EtchedBorder with the specified appearance,
explicitly selecting the colors that will be used for
highlight and shadow.
|
Modifier and Type | Method and Description |
---|---|
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.
|
int |
getEtchType()
|
Color |
getHighlightColor()
Returns the color that will be used for highlighted parts when
painting the border, or
null if that color will be
derived from the background of the enclosed Component. |
Color |
getHighlightColor(Component c)
Determines the color that will be used for highlighted parts when
painting the border around a given component.
|
Color |
getShadowColor()
Returns the color that will be used for shadowed parts when
painting the border, or
null if that color will be
derived from the background of the enclosed Component. |
Color |
getShadowColor(Component c)
Determines the color that will be used for shadowed parts when
painting the border around a given component.
|
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)
Paints the border for a given component.
|
getInteriorRectangle, getInteriorRectangle
public static final int RAISED
public static final int LOWERED
protected int etchType
protected Color highlight
null
to indicate that the
color shall be derived from the background of the enclosed
component.public EtchedBorder()
public EtchedBorder(int etchType)
etchType
- the desired appearance of the border. The value
must be either RAISED
or LOWERED
.IllegalArgumentException
- if etchType
has
an unsupported value.public EtchedBorder(Color highlight, Color shadow)
highlight
- the color that will be used for painting
the highlight part of the border.shadow
- the color that will be used for painting
the shadow part of the border.EtchedBorder(int, Color, Color)
public EtchedBorder(int etchType, Color highlight, Color shadow)
etchType
- the desired appearance of the border. The value
must be either RAISED
or LOWERED
.highlight
- the color that will be used for painting
the highlight part of the border.shadow
- the color that will be used for painting
the shadow part of the border.IllegalArgumentException
- if etchType
has
an unsupported value.public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
paintBorder
in interface Border
paintBorder
in class AbstractBorder
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.public Insets getBorderInsets(Component c)
getBorderInsets
in interface Border
getBorderInsets
in class AbstractBorder
c
- the component whose border is to be measured.left
, right
,
top
and bottom
fields indicate the
width of the border at the respective edge.getBorderInsets(java.awt.Component, java.awt.Insets)
public Insets getBorderInsets(Component c, Insets insets)
getBorderInsets
in class AbstractBorder
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).insets
.getBorderInsets(Component)
public boolean isBorderOpaque()
If the border colors are derived from the background color of
the enclosed component, the result is true
because
the derivation method always returns opaque colors. Otherwise,
the result depends on the opacity of the individual colors.
isBorderOpaque
in interface Border
isBorderOpaque
in class AbstractBorder
true
if the border is fully opaque, or
false
if some pixels of the background
can shine through the border.public int getEtchType()
public Color getHighlightColor(Component c)
c
- the component enclosed by this border.Component.getBackground()
,
Color.brighter()
public Color getHighlightColor()
null
if that color will be
derived from the background of the enclosed Component.null
).public Color getShadowColor(Component c)
c
- the component enclosed by this border.Component.getBackground()
,
Color.darker()
public Color getShadowColor()
null
if that color will be
derived from the background of the enclosed Component.null
).