jdk/src/share/classes/javax/swing/border/BevelBorder.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8142 df12f485c6bd
child 20458 f2423fb3fd19
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8142
diff changeset
     2
 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.beans.ConstructorProperties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A class which implements a simple two-line bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class BevelBorder extends AbstractBorder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /** Raised bevel type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public static final int RAISED  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /** Lowered bevel type. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public static final int LOWERED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    protected int bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected Color highlightOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    protected Color highlightInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected Color shadowInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected Color shadowOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Creates a bevel border with the specified type and whose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * colors will be derived from the background color of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * component passed into the paintBorder method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public BevelBorder(int bevelType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.bevelType = bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Creates a bevel border with the specified type, highlight and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * shadow colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param highlight the color to use for the bevel highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param shadow the color to use for the bevel shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public BevelBorder(int bevelType, Color highlight, Color shadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        this(bevelType, highlight.brighter(), highlight, shadow, shadow.brighter());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Creates a bevel border with the specified type, highlight and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * shadow colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param bevelType the type of bevel for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param highlightOuterColor the color to use for the bevel outer highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param highlightInnerColor the color to use for the bevel inner highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @param shadowOuterColor the color to use for the bevel outer shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param shadowInnerColor the color to use for the bevel inner shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    @ConstructorProperties({"bevelType", "highlightOuterColor", "highlightInnerColor", "shadowOuterColor", "shadowInnerColor"})
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public BevelBorder(int bevelType, Color highlightOuterColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                       Color highlightInnerColor, Color shadowOuterColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                       Color shadowInnerColor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        this(bevelType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        this.highlightOuter = highlightOuterColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.highlightInner = highlightInnerColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.shadowOuter = shadowOuterColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this.shadowInner = shadowInnerColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Paints the border for the specified component with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * position and size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @param c the component for which this border is being painted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param g the paint graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @param x the x position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param y the y position of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @param width the width of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param height the height of the painted border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        if (bevelType == RAISED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
             paintRaisedBevel(c, g, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        } else if (bevelType == LOWERED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
             paintLoweredBevel(c, g, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Reinitialize the insets parameter with this Border's current Insets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param c the component for which this border insets value applies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param insets the object to be reinitialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        insets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Returns the outer highlight color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * when rendered on the specified component.  If no highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * color was specified at instantiation, the highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @param c the component for which the highlight may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public Color getHighlightOuterColor(Component c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        Color highlight = getHighlightOuterColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return highlight != null? highlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                                       c.getBackground().brighter().brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Returns the inner highlight color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * when rendered on the specified component.  If no highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * color was specified at instantiation, the highlight color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param c the component for which the highlight may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public Color getHighlightInnerColor(Component c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        Color highlight = getHighlightInnerColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return highlight != null? highlight :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                       c.getBackground().brighter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Returns the inner shadow color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * when rendered on the specified component.  If no shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * color was specified at instantiation, the shadow color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @param c the component for which the shadow may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public Color getShadowInnerColor(Component c)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        Color shadow = getShadowInnerColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return shadow != null? shadow :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                    c.getBackground().darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * Returns the outer shadow color of the bevel border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * when rendered on the specified component.  If no shadow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * color was specified at instantiation, the shadow color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * is derived from the specified component's background color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param c the component for which the shadow may be derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public Color getShadowOuterColor(Component c)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        Color shadow = getShadowOuterColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return shadow != null? shadow :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                                    c.getBackground().darker().darker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Returns the outer highlight color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Will return null if no highlight color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public Color getHighlightOuterColor()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return highlightOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Returns the inner highlight color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Will return null if no highlight color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public Color getHighlightInnerColor()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return highlightInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Returns the inner shadow color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Will return null if no shadow color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public Color getShadowInnerColor()      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        return shadowInner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * Returns the outer shadow color of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Will return null if no shadow color was specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * at instantiation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public Color getShadowOuterColor()      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        return shadowOuter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * Returns the type of the bevel border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public int getBevelType()       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return bevelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Returns whether or not the border is opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public boolean isBorderOpaque() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                                    int width, int height)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        g.setColor(getHighlightOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        g.drawLine(0, 0, 0, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        g.drawLine(1, 0, w-2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        g.setColor(getHighlightInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        g.drawLine(1, 1, 1, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        g.drawLine(2, 1, w-3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        g.setColor(getShadowOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        g.drawLine(0, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        g.drawLine(w-1, 0, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        g.setColor(getShadowInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        g.drawLine(1, h-2, w-2, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        g.drawLine(w-2, 1, w-2, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    protected void paintLoweredBevel(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                        int width, int height)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        int h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        int w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        g.setColor(getShadowInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        g.drawLine(0, 0, 0, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        g.drawLine(1, 0, w-1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        g.setColor(getShadowOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        g.drawLine(1, 1, 1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        g.drawLine(2, 1, w-2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        g.setColor(getHighlightOuterColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        g.drawLine(1, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        g.drawLine(w-1, 1, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        g.setColor(getHighlightInnerColor(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        g.drawLine(2, h-2, w-2, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        g.drawLine(w-2, 2, w-2, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
}