Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.swing.border
Class BevelBorder  view BevelBorder download BevelBorder.java

java.lang.Object
  extended byjavax.swing.border.AbstractBorder
      extended byjavax.swing.border.BevelBorder
All Implemented Interfaces:
Border, java.io.Serializable
Direct Known Subclasses:
SoftBevelBorder

public class BevelBorder
extends AbstractBorder

A rectangular, two pixel thick border that causes the enclosed area to appear as if it was raising out of or lowered into the screen. Some LookAndFeels use this kind of border for rectangular buttons.

A BevelBorder has a highlight and a shadow color. In the raised variant, the highlight color is used for the top and left edges, and the shadow color is used for the bottom and right edge. For an image, see the documentation of the individual constructors.


Field Summary
protected  int bevelType
          The type of this BevelBorder, which is either RAISED 55 or LOWERED 55 .
protected  java.awt.Color highlightInner
          The inner highlight color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.
protected  java.awt.Color highlightOuter
          The outer highlight color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.
static int LOWERED
          Indicates that the BevelBorder looks like if the enclosed area was pressed into the screen.
static int RAISED
          Indicates that the BevelBorder looks like if the enclosed area was raising out of the screen.
(package private) static long serialVersionUID
          Determined using the serialver tool of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
protected  java.awt.Color shadowInner
          The inner shadow color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.
protected  java.awt.Color shadowOuter
          The outer shadow color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.
 
Constructor Summary
BevelBorder(int bevelType)
          Constructs a BevelBorder whose colors will be derived from the background of the enclosed component.
BevelBorder(int bevelType, java.awt.Color highlight, java.awt.Color shadow)
          Constructs a BevelBorder given its appearance type and two colors for its highlight and shadow.
BevelBorder(int bevelType, java.awt.Color highlightOuter, java.awt.Color highlightInner, java.awt.Color shadowOuter, java.awt.Color shadowInner)
          Constructs a BevelBorder given its appearance type and all colors.
 
Method Summary
 int getBevelType()
          Returns the appearance of this border, which is either RAISED 55 or LOWERED 55 .
 java.awt.Insets getBorderInsets(java.awt.Component c)
          Measures the width of this border.
 java.awt.Insets getBorderInsets(java.awt.Component c, java.awt.Insets insets)
          Measures the width of this border, storing the results into a pre-existing Insets object.
 java.awt.Color getHighlightInnerColor()
          Returns the color that will be used for the inner side of highlighted edges when painting the border, or null if that color will be derived from the background of the enclosed Component.
 java.awt.Color getHighlightInnerColor(java.awt.Component c)
          Determines the color that will be used for the inner side of highlighted edges when painting the border.
 java.awt.Color getHighlightOuterColor()
          Returns the color that will be used for the outer side of highlighted edges when painting the border, or null if that color will be derived from the background of the enclosed Component.
 java.awt.Color getHighlightOuterColor(java.awt.Component c)
          Determines the color that will be used for the outer side of highlighted edges when painting the border.
 java.awt.Color getShadowInnerColor()
          Returns the color that will be used for the inner side of shadowed edges when painting the border, or null if that color will be derived from the background of the enclosed Component.
 java.awt.Color getShadowInnerColor(java.awt.Component c)
          Determines the color that will be used for the inner side of shadowed edges when painting the border.
 java.awt.Color getShadowOuterColor()
          Returns the color that will be used for the outer side of shadowed edges when painting the border, or null if that color will be derived from the background of the enclosed Component.
 java.awt.Color getShadowOuterColor(java.awt.Component c)
          Determines the color that will be used for the outer side of shadowed edges when painting the border.
 boolean isBorderOpaque()
          Determines whether this border fills every pixel in its area when painting.
private static void paintBevel(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color a, java.awt.Color b, java.awt.Color c, java.awt.Color d)
          Paints a two-pixel bevel in four colors.
 void paintBorder(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
          Paints the border for a given component.
protected  void paintLoweredBevel(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
          Paints a lowered bevel border around a component.
protected  void paintRaisedBevel(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
          Paints a raised bevel border around a component.
 
Methods inherited from class javax.swing.border.AbstractBorder
getInteriorRectangle, getInteriorRectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Determined using the serialver tool of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.

See Also:
Constant Field Values

RAISED

public static final int RAISED
Indicates that the BevelBorder looks like if the enclosed area was raising out of the screen.

See Also:
Constant Field Values

LOWERED

public static final int LOWERED
Indicates that the BevelBorder looks like if the enclosed area was pressed into the screen.

See Also:
Constant Field Values

bevelType

protected int bevelType
The type of this BevelBorder, which is either RAISED 55 or LOWERED 55 .


highlightOuter

protected java.awt.Color highlightOuter
The outer highlight color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.


highlightInner

protected java.awt.Color highlightInner
The inner highlight color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.


shadowOuter

protected java.awt.Color shadowOuter
The outer shadow color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.


shadowInner

protected java.awt.Color shadowInner
The inner shadow color, or null to indicate that the color shall be derived from the background of the component whose border is being painted.

Constructor Detail

BevelBorder

public BevelBorder(int bevelType)
Constructs a BevelBorder whose colors will be derived from the background of the enclosed component. The background color is retrieved each time the border is painted, so a BevelBorder constructed by this method will automatically reflect a change to the component’s background color.

[An illustration showing raised and lowered BevelBorders]


BevelBorder

public BevelBorder(int bevelType,
                   java.awt.Color highlight,
                   java.awt.Color shadow)
Constructs a BevelBorder given its appearance type and two colors for its highlight and shadow.

[An illustration showing BevelBorders that were constructed
 with this method]


BevelBorder

public BevelBorder(int bevelType,
                   java.awt.Color highlightOuter,
                   java.awt.Color highlightInner,
                   java.awt.Color shadowOuter,
                   java.awt.Color shadowInner)
Constructs a BevelBorder given its appearance type and all colors.

[An illustration showing BevelBorders that were constructed
 with this method]

Method Detail

paintBorder

public void paintBorder(java.awt.Component c,
                        java.awt.Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
Paints the border for a given component.

Specified by:
paintBorder in interface Border
Overrides:
paintBorder in class AbstractBorder

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c)
Measures the width of this border.

Specified by:
getBorderInsets in interface Border
Overrides:
getBorderInsets in class AbstractBorder

getBorderInsets

public java.awt.Insets getBorderInsets(java.awt.Component c,
                                       java.awt.Insets insets)
Measures the width of this border, storing the results into a pre-existing Insets object.

Overrides:
getBorderInsets in class AbstractBorder

getHighlightOuterColor

public java.awt.Color getHighlightOuterColor(java.awt.Component c)
Determines the color that will be used for the outer side of highlighted edges when painting the border. If a highlight color has been specified upon constructing the border, that color is returned. Otherwise, the inner highlight color is brightened.


getHighlightInnerColor

public java.awt.Color getHighlightInnerColor(java.awt.Component c)
Determines the color that will be used for the inner side of highlighted edges when painting the border. If a highlight color has been specified upon constructing the border, that color is returned. Otherwise, the background color of the enclosed component is brightened.


getShadowInnerColor

public java.awt.Color getShadowInnerColor(java.awt.Component c)
Determines the color that will be used for the inner side of shadowed edges when painting the border. If a shadow color has been specified upon constructing the border, that color is returned. Otherwise, the background color of the enclosed component is darkened.


getShadowOuterColor

public java.awt.Color getShadowOuterColor(java.awt.Component c)
Determines the color that will be used for the outer side of shadowed edges when painting the border. If a shadow color has been specified upon constructing the border, that color is returned. Otherwise, the inner shadow color is darkened.


getHighlightOuterColor

public java.awt.Color getHighlightOuterColor()
Returns the color that will be used for the outer side of highlighted edges when painting the border, or null if that color will be derived from the background of the enclosed Component.


getHighlightInnerColor

public java.awt.Color getHighlightInnerColor()
Returns the color that will be used for the inner side of highlighted edges when painting the border, or null if that color will be derived from the background of the enclosed Component.


getShadowInnerColor

public java.awt.Color getShadowInnerColor()
Returns the color that will be used for the inner side of shadowed edges when painting the border, or null if that color will be derived from the background of the enclosed Component.


getShadowOuterColor

public java.awt.Color getShadowOuterColor()
Returns the color that will be used for the outer side of shadowed edges when painting the border, or null if that color will be derived from the background of the enclosed Component.


getBevelType

public int getBevelType()
Returns the appearance of this border, which is either RAISED 55 or LOWERED 55 .


isBorderOpaque

public boolean isBorderOpaque()
Determines whether this border fills every pixel in its area when painting.

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.

Specified by:
isBorderOpaque in interface Border
Overrides:
isBorderOpaque in class AbstractBorder

paintRaisedBevel

protected void paintRaisedBevel(java.awt.Component c,
                                java.awt.Graphics g,
                                int x,
                                int y,
                                int width,
                                int height)
Paints a raised bevel border around a component.


paintLoweredBevel

protected void paintLoweredBevel(java.awt.Component c,
                                 java.awt.Graphics g,
                                 int x,
                                 int y,
                                 int width,
                                 int height)
Paints a lowered bevel border around a component.


paintBevel

private static void paintBevel(java.awt.Graphics g,
                               int x,
                               int y,
                               int width,
                               int height,
                               java.awt.Color a,
                               java.awt.Color b,
                               java.awt.Color c,
                               java.awt.Color d)
Paints a two-pixel bevel in four colors.
 ++++++++++++
 +..........#    + = color a
 +.        X#    . = color b
 +.        X#    X = color c
 +.XXXXXXXXX#    # = color d
 ############