BevelBorderpublic class BevelBorder extends AbstractBorder A class which implements a simple two-line bevel border.
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 bevel type. | public static final int | LOWEREDLowered bevel type. | protected int | bevelType | protected Color | highlightOuter | protected Color | highlightInner | protected Color | shadowInner | protected Color | shadowOuter |
Constructors Summary |
---|
public BevelBorder(int bevelType)Creates a bevel border with the specified type and whose
colors will be derived from the background color of the
component passed into the paintBorder method.
this.bevelType = bevelType;
| public BevelBorder(int bevelType, Color highlight, Color shadow)Creates a bevel border with the specified type, highlight and
shadow colors.
this(bevelType, highlight.brighter(), highlight, shadow, shadow.brighter());
| public BevelBorder(int bevelType, Color highlightOuterColor, Color highlightInnerColor, Color shadowOuterColor, Color shadowInnerColor)Creates a bevel border with the specified type, highlight and
shadow colors.
Note: The shadow inner and outer colors are
switched for a lowered bevel border.
this(bevelType);
this.highlightOuter = highlightOuterColor;
this.highlightInner = highlightInnerColor;
this.shadowOuter = shadowOuterColor;
this.shadowInner = shadowInnerColor;
|
Methods Summary |
---|
public int | getBevelType()Returns the type of the bevel border.
return bevelType;
| 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 java.awt.Color | getHighlightInnerColor()Returns the inner highlight color of the bevel border.
Will return null if no highlight color was specified
at instantiation.
return highlightInner;
| public java.awt.Color | getHighlightInnerColor(java.awt.Component c)Returns the inner highlight color of the bevel 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.
Color highlight = getHighlightInnerColor();
return highlight != null? highlight :
c.getBackground().brighter();
| public java.awt.Color | getHighlightOuterColor()Returns the outer highlight color of the bevel border.
Will return null if no highlight color was specified
at instantiation.
return highlightOuter;
| public java.awt.Color | getHighlightOuterColor(java.awt.Component c)Returns the outer highlight color of the bevel 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.
Color highlight = getHighlightOuterColor();
return highlight != null? highlight :
c.getBackground().brighter().brighter();
| public java.awt.Color | getShadowInnerColor()Returns the inner shadow color of the bevel border.
Will return null if no shadow color was specified
at instantiation.
return shadowInner;
| public java.awt.Color | getShadowInnerColor(java.awt.Component c)Returns the inner shadow color of the bevel 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.
Color shadow = getShadowInnerColor();
return shadow != null? shadow :
c.getBackground().darker();
| public java.awt.Color | getShadowOuterColor(java.awt.Component c)Returns the outer shadow color of the bevel 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.
Color shadow = getShadowOuterColor();
return shadow != null? shadow :
c.getBackground().darker().darker();
| public java.awt.Color | getShadowOuterColor()Returns the outer shadow color of the bevel border.
Will return null if no shadow color was specified
at instantiation.
return shadowOuter;
| 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.
if (bevelType == RAISED) {
paintRaisedBevel(c, g, x, y, width, height);
} else if (bevelType == LOWERED) {
paintLoweredBevel(c, g, x, y, width, height);
}
| protected void | paintLoweredBevel(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
Color oldColor = g.getColor();
int h = height;
int w = width;
g.translate(x, y);
g.setColor(getShadowInnerColor(c));
g.drawLine(0, 0, 0, h-1);
g.drawLine(1, 0, w-1, 0);
g.setColor(getShadowOuterColor(c));
g.drawLine(1, 1, 1, h-2);
g.drawLine(2, 1, w-2, 1);
g.setColor(getHighlightOuterColor(c));
g.drawLine(1, h-1, w-1, h-1);
g.drawLine(w-1, 1, w-1, h-2);
g.setColor(getHighlightInnerColor(c));
g.drawLine(2, h-2, w-2, h-2);
g.drawLine(w-2, 2, w-2, h-3);
g.translate(-x, -y);
g.setColor(oldColor);
| protected void | paintRaisedBevel(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
Color oldColor = g.getColor();
int h = height;
int w = width;
g.translate(x, y);
g.setColor(getHighlightOuterColor(c));
g.drawLine(0, 0, 0, h-2);
g.drawLine(1, 0, w-2, 0);
g.setColor(getHighlightInnerColor(c));
g.drawLine(1, 1, 1, h-3);
g.drawLine(2, 1, w-3, 1);
g.setColor(getShadowOuterColor(c));
g.drawLine(0, h-1, w-1, h-1);
g.drawLine(w-1, 0, w-1, h-2);
g.setColor(getShadowInnerColor(c));
g.drawLine(1, h-2, w-2, h-2);
g.drawLine(w-2, 1, w-2, h-3);
g.translate(-x, -y);
g.setColor(oldColor);
|
|