EtchedBorderpublic class EtchedBorder extends AbstractBorder 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 JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
Fields Summary |
---|
public static final int | RAISEDRaised etched type. | public static final int | LOWEREDLowered etched type. | protected int | etchType | protected Color | highlight | protected Color | shadow |
Constructors 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.
this(LOWERED);
| 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.
this(etchType, null, null);
| public EtchedBorder(Color highlight, Color shadow)Creates a lowered etched border with the specified highlight and
shadow colors.
this(LOWERED, highlight, shadow);
| public EtchedBorder(int etchType, Color highlight, Color shadow)Creates an etched border with the specified etch-type,
highlight and shadow colors.
this.etchType = etchType;
this.highlight = highlight;
this.shadow = shadow;
|
Methods Summary |
---|
public java.awt.Insets | getBorderInsets(java.awt.Component c)Returns the insets of the border.
return new Insets(2, 2, 2, 2);
| public java.awt.Insets | getBorderInsets(java.awt.Component c, java.awt.Insets insets)Reinitialize the insets parameter with this Border's current Insets.
insets.left = insets.top = insets.right = insets.bottom = 2;
return insets;
| public int | getEtchType()Returns which etch-type is set on the etched border.
return etchType;
| public java.awt.Color | getHighlightColor(java.awt.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.
return highlight != null? highlight :
c.getBackground().brighter();
| public java.awt.Color | getHighlightColor()Returns the highlight color of the etched border.
Will return null if no highlight color was specified
at instantiation.
return highlight;
| public java.awt.Color | getShadowColor(java.awt.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.
return shadow != null? shadow : c.getBackground().darker();
| public java.awt.Color | getShadowColor()Returns the shadow color of the etched border.
Will return null if no shadow color was specified
at instantiation.
return shadow;
| public boolean | isBorderOpaque()Returns whether or not the border is opaque. return true;
| public void | paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)Paints the border for the specified component with the
specified position and size.
int w = width;
int h = height;
g.translate(x, y);
g.setColor(etchType == LOWERED? getShadowColor(c) : getHighlightColor(c));
g.drawRect(0, 0, w-2, h-2);
g.setColor(etchType == LOWERED? getHighlightColor(c) : getShadowColor(c));
g.drawLine(1, h-3, 1, 1);
g.drawLine(1, 1, w-3, 1);
g.drawLine(0, h-1, w-1, h-1);
g.drawLine(w-1, h-1, w-1, 0);
g.translate(-x, -y);
|
|