jdk/src/share/classes/javax/swing/border/BevelBorder.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.beans.ConstructorProperties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A class which implements a simple two-line bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class BevelBorder extends AbstractBorder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /** Raised bevel type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public static final int RAISED  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /** Lowered bevel type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public static final int LOWERED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected int bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    protected Color highlightOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected Color highlightInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected Color shadowInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    protected Color shadowOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Creates a bevel border with the specified type and whose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * colors will be derived from the background color of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * component passed into the paintBorder method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public BevelBorder(int bevelType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        this.bevelType = bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Creates a bevel border with the specified type, highlight and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * shadow colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param highlight the color to use for the bevel highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param shadow the color to use for the bevel shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public BevelBorder(int bevelType, Color highlight, Color shadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        this(bevelType, highlight.brighter(), highlight, shadow, shadow.brighter());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Creates a bevel border with the specified type, highlight and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * shadow colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Note: The shadow inner and outer colors are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * switched for a lowered bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param highlightOuterColor the color to use for the bevel outer highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param highlightInnerColor the color to use for the bevel inner highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param shadowOuterColor the color to use for the bevel outer shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param shadowInnerColor the color to use for the bevel inner shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    @ConstructorProperties({"bevelType", "highlightOuterColor", "highlightInnerColor", "shadowOuterColor", "shadowInnerColor"})
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public BevelBorder(int bevelType, Color highlightOuterColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                       Color highlightInnerColor, Color shadowOuterColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                       Color shadowInnerColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this(bevelType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.highlightOuter = highlightOuterColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        this.highlightInner = highlightInnerColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.shadowOuter = shadowOuterColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        this.shadowInner = shadowInnerColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Paints the border for the specified component with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * position and size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param c the component for which this border is being painted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param g the paint graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param x the x position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param y the y position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param width the width of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @param height the height of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (bevelType == RAISED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
             paintRaisedBevel(c, g, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        } else if (bevelType == LOWERED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
             paintLoweredBevel(c, g, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Reinitialize the insets parameter with this Border's current Insets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param c the component for which this border insets value applies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param insets the object to be reinitialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        insets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Returns the outer highlight color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * when rendered on the specified component.  If no highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * color was specified at instantiation, the highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @param c the component for which the highlight may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public Color getHighlightOuterColor(Component c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        Color highlight = getHighlightOuterColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return highlight != null? highlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                       c.getBackground().brighter().brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * Returns the inner highlight color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * when rendered on the specified component.  If no highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * color was specified at instantiation, the highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param c the component for which the highlight may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    public Color getHighlightInnerColor(Component c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        Color highlight = getHighlightInnerColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        return highlight != null? highlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                       c.getBackground().brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Returns the inner shadow color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * when rendered on the specified component.  If no shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * color was specified at instantiation, the shadow color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param c the component for which the shadow may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public Color getShadowInnerColor(Component c)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        Color shadow = getShadowInnerColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return shadow != null? shadow :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                    c.getBackground().darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Returns the outer shadow color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * when rendered on the specified component.  If no shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * color was specified at instantiation, the shadow color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @param c the component for which the shadow may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public Color getShadowOuterColor(Component c)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        Color shadow = getShadowOuterColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return shadow != null? shadow :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                                    c.getBackground().darker().darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * Returns the outer highlight color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Will return null if no highlight color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public Color getHighlightOuterColor()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return highlightOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * Returns the inner highlight color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Will return null if no highlight color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public Color getHighlightInnerColor()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        return highlightInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Returns the inner shadow color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Will return null if no shadow color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public Color getShadowInnerColor()      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return shadowInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Returns the outer shadow color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Will return null if no shadow color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    public Color getShadowOuterColor()      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        return shadowOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Returns the type of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public int getBevelType()       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Returns whether or not the border is opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public boolean isBorderOpaque() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                                    int width, int height)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        g.setColor(getHighlightOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        g.drawLine(0, 0, 0, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        g.drawLine(1, 0, w-2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        g.setColor(getHighlightInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        g.drawLine(1, 1, 1, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        g.drawLine(2, 1, w-3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        g.setColor(getShadowOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        g.drawLine(0, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        g.drawLine(w-1, 0, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        g.setColor(getShadowInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        g.drawLine(1, h-2, w-2, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        g.drawLine(w-2, 1, w-2, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    protected void paintLoweredBevel(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                                        int width, int height)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        g.setColor(getShadowInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        g.drawLine(0, 0, 0, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        g.drawLine(1, 0, w-1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        g.setColor(getShadowOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        g.drawLine(1, 1, 1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        g.drawLine(2, 1, w-2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        g.setColor(getHighlightOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        g.drawLine(1, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        g.drawLine(w-1, 1, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        g.setColor(getHighlightInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        g.drawLine(2, h-2, w-2, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        g.drawLine(w-2, 2, w-2, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
}