jdk/src/share/classes/javax/swing/BorderFactory.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8142 df12f485c6bd
child 12411 a85a15e74ad5
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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
7006
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
    27
import java.awt.BasicStroke;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Font;
7006
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
    30
import java.awt.Paint;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Factory class for vending standard <code>Border</code> objects.  Wherever
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * possible, this factory will hand out references to shared
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <code>Border</code> instances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * For further information and examples see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/border.html">How
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 to Use Borders</a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * a section in <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public class BorderFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /** Don't let anyone instantiate this class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private BorderFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
//// LineBorder ///////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Creates a line border withe the specified color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @param color  a <code>Color</code> to use for the line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public static Border createLineBorder(Color color) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        return new LineBorder(color, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Creates a line border with the specified color
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * and width. The width applies to all four sides of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * border. To specify widths individually for the top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * bottom, left, and right, use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * {@link #createMatteBorder(int,int,int,int,Color)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param color  a <code>Color</code> to use for the line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param thickness  an integer specifying the width in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public static Border createLineBorder(Color color, int thickness)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return new LineBorder(color, thickness);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
5765
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    78
    /**
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    79
     * Creates a line border with the specified color, thickness, and corner shape.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    80
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    81
     * @param color      the color of the border
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    82
     * @param thickness  the thickness of the border
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    83
     * @param rounded    whether or not border corners should be round
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    84
     * @return the {@code Border} object
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    85
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    86
     * @see LineBorder#LineBorder(Color, int, boolean)
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    87
     * @since 1.7
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    88
     */
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    89
    public static Border createLineBorder(Color color, int thickness, boolean rounded) {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    90
        return new LineBorder(color, thickness, rounded);
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
    91
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
//// BevelBorder /////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
///////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    static final Border sharedRaisedBevel = new BevelBorder(BevelBorder.RAISED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    static final Border sharedLoweredBevel = new BevelBorder(BevelBorder.LOWERED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Creates a border with a raised beveled edge, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * brighter shades of the component's current background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * for highlighting, and darker shading for shadows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * (In a raised border, highlights are on top and shadows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *  are underneath.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static Border createRaisedBevelBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return createSharedBevel(BevelBorder.RAISED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Creates a border with a lowered beveled edge, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * brighter shades of the component's current background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * for highlighting, and darker shading for shadows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * (In a lowered border, shadows are on top and highlights
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *  are underneath.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public static Border createLoweredBevelBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return createSharedBevel(BevelBorder.LOWERED);
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
     * Creates a beveled border of the specified type, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * brighter shades of the component's current background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * for highlighting, and darker shading for shadows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * (In a lowered border, shadows are on top and highlights
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *  are underneath.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param type  an integer specifying either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *                  <code>BevelBorder.LOWERED</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *                  <code>BevelBorder.RAISED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public static Border createBevelBorder(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return createSharedBevel(type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Creates a beveled border of the specified type, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * the specified highlighting and shadowing. The outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * edge of the highlighted area uses a brighter shade of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * the highlight color. The inner edge of the shadow area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * uses a brighter shade of the shadow color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param type  an integer specifying either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *                  <code>BevelBorder.LOWERED</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *                  <code>BevelBorder.RAISED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param highlight  a <code>Color</code> object for highlights
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param shadow     a <code>Color</code> object for shadows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public static Border createBevelBorder(int type, Color highlight, Color shadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return new BevelBorder(type, highlight, shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Creates a beveled border of the specified type, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * the specified colors for the inner and outer highlight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * and shadow areas.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @param type  an integer specifying either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *          <code>BevelBorder.LOWERED</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *          <code>BevelBorder.RAISED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param highlightOuter  a <code>Color</code> object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *                  outer edge of the highlight area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param highlightInner  a <code>Color</code> object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *                  inner edge of the highlight area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param shadowOuter     a <code>Color</code> object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *                  outer edge of the shadow area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param shadowInner     a <code>Color</code> object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *                  inner edge of the shadow area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public static Border createBevelBorder(int type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                        Color highlightOuter, Color highlightInner,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                        Color shadowOuter, Color shadowInner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return new BevelBorder(type, highlightOuter, highlightInner,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                        shadowOuter, shadowInner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    static Border createSharedBevel(int type)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if(type == BevelBorder.RAISED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            return sharedRaisedBevel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        } else if(type == BevelBorder.LOWERED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return sharedLoweredBevel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
5765
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   191
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   192
//// SoftBevelBorder ///////////////////////////////////////////////////////////
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   193
////////////////////////////////////////////////////////////////////////////////
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   194
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   195
    private static Border sharedSoftRaisedBevel;
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   196
    private static Border sharedSoftLoweredBevel;
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   197
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   198
    /**
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   199
     * Creates a beveled border with a raised edge and softened corners,
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   200
     * using brighter shades of the component's current background color
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   201
     * for highlighting, and darker shading for shadows.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   202
     * In a raised border, highlights are on top and shadows are underneath.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   203
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   204
     * @return the {@code Border} object
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   205
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   206
     * @since 1.7
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   207
     */
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   208
    public static Border createRaisedSoftBevelBorder() {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   209
        if (sharedSoftRaisedBevel == null) {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   210
            sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED);
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   211
        }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   212
        return sharedSoftRaisedBevel;
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   213
    }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   214
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   215
    /**
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   216
     * Creates a beveled border with a lowered edge and softened corners,
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   217
     * using brighter shades of the component's current background color
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   218
     * for highlighting, and darker shading for shadows.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   219
     * In a lowered border, shadows are on top and highlights are underneath.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   220
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   221
     * @return the {@code Border} object
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   222
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   223
     * @since 1.7
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   224
     */
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   225
    public static Border createLoweredSoftBevelBorder() {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   226
        if (sharedSoftLoweredBevel == null) {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   227
            sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED);
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   228
        }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   229
        return sharedSoftLoweredBevel;
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   230
    }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   231
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   232
    /**
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   233
     * Creates a beveled border of the specified type with softened corners,
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   234
     * using brighter shades of the component's current background color
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   235
     * for highlighting, and darker shading for shadows.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   236
     * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   237
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   238
     * @param type  a type of a bevel
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   239
     * @return the {@code Border} object or {@code null}
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   240
     *         if the specified type is not valid
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   241
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   242
     * @see BevelBorder#BevelBorder(int)
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   243
     * @since 1.7
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   244
     */
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   245
    public static Border createSoftBevelBorder(int type) {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   246
        if (type == BevelBorder.RAISED) {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   247
            return createRaisedSoftBevelBorder();
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   248
        }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   249
        if (type == BevelBorder.LOWERED) {
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   250
            return createLoweredSoftBevelBorder();
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   251
        }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   252
        return null;
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   253
    }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   254
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   255
    /**
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   256
     * Creates a beveled border of the specified type with softened corners,
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   257
     * using the specified highlighting and shadowing.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   258
     * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   259
     * The outer edge of the highlight area uses
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   260
     * a brighter shade of the {@code highlight} color.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   261
     * The inner edge of the shadow area uses
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   262
     * a brighter shade of the {@code shadow} color.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   263
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   264
     * @param type       a type of a bevel
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   265
     * @param highlight  a basic color of the highlight area
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   266
     * @param shadow     a basic color of the shadow area
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   267
     * @return the {@code Border} object
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   268
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   269
     * @see BevelBorder#BevelBorder(int, Color, Color)
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   270
     * @since 1.7
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   271
     */
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   272
    public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) {
7262
9b7a8d4e0e18 6999033: Methods BorderFactory.createSoftBevelBorder() don't return SoftBevelBorder instances
malenkov
parents: 7006
diff changeset
   273
        return new SoftBevelBorder(type, highlight, shadow);
5765
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   274
    }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   275
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   276
    /**
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   277
     * Creates a beveled border of the specified type with softened corners,
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   278
     * using the specified colors for the inner and outer edges
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   279
     * of the highlight and the shadow areas.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   280
     * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   281
     * Note: The shadow inner and outer colors are switched
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   282
     * for a lowered bevel border.
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   283
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   284
     * @param type            a type of a bevel
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   285
     * @param highlightOuter  a color of the outer edge of the highlight area
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   286
     * @param highlightInner  a color of the inner edge of the highlight area
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   287
     * @param shadowOuter     a color of the outer edge of the shadow area
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   288
     * @param shadowInner     a color of the inner edge of the shadow area
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   289
     * @return the {@code Border} object
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   290
     *
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   291
     * @see BevelBorder#BevelBorder(int, Color, Color, Color, Color)
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   292
     * @since 1.7
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   293
     */
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   294
    public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) {
7262
9b7a8d4e0e18 6999033: Methods BorderFactory.createSoftBevelBorder() don't return SoftBevelBorder instances
malenkov
parents: 7006
diff changeset
   295
        return new SoftBevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner);
5765
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   296
    }
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   297
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
//// EtchedBorder ///////////////////////////////////////////////////////////
5765
b9ebe03ab870 5066685: BorderFactory lacks SoftBevelBorder support
malenkov
parents: 5506
diff changeset
   299
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    static final Border sharedEtchedBorder = new EtchedBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    private static Border sharedRaisedEtchedBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * Creates a border with an "etched" look using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * the component's current background color for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * highlighting and shading.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public static Border createEtchedBorder()    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        return sharedEtchedBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * Creates a border with an "etched" look using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * the specified highlighting and shading colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @param highlight  a <code>Color</code> object for the border highlights
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @param shadow     a <code>Color</code> object for the border shadows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    public static Border createEtchedBorder(Color highlight, Color shadow)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        return new EtchedBorder(highlight, shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * Creates a border with an "etched" look using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * the component's current background color for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * highlighting and shading.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @param type      one of <code>EtchedBorder.RAISED</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *                  <code>EtchedBorder.LOWERED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @exception IllegalArgumentException if type is not either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *                  <code>EtchedBorder.RAISED</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *                  <code>EtchedBorder.LOWERED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public static Border createEtchedBorder(int type)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        case EtchedBorder.RAISED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            if (sharedRaisedEtchedBorder == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                sharedRaisedEtchedBorder = new EtchedBorder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                                           (EtchedBorder.RAISED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            return sharedRaisedEtchedBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        case EtchedBorder.LOWERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            return sharedEtchedBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            throw new IllegalArgumentException("type must be one of EtchedBorder.RAISED or EtchedBorder.LOWERED");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Creates a border with an "etched" look using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * the specified highlighting and shading colors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @param type      one of <code>EtchedBorder.RAISED</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     *                  <code>EtchedBorder.LOWERED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @param highlight  a <code>Color</code> object for the border highlights
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @param shadow     a <code>Color</code> object for the border shadows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public static Border createEtchedBorder(int type, Color highlight,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                                            Color shadow)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return new EtchedBorder(type, highlight, shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
//// TitledBorder ////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * Creates a new titled border with the specified title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * the default border type (determined by the current look and feel),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * the default text position (sitting on the top line),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * the default justification (leading), and the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * font and text color (determined by the current look and feel).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @param title      a <code>String</code> containing the text of the title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * @return the <code>TitledBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    public static TitledBorder createTitledBorder(String title)     {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        return new TitledBorder(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Creates a new titled border with an empty title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * the specified border object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * the default text position (sitting on the top line),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * the default justification (leading), and the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * font and text color (determined by the current look and feel).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @param border     the <code>Border</code> object to add the title to; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *                   <code>null</code> the <code>Border</code> is determined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *                   by the current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @return the <code>TitledBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    public static TitledBorder createTitledBorder(Border border)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        return new TitledBorder(border);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Adds a title to an existing border,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * with default positioning (sitting on the top line),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * default justification (leading) and the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * font and text color (determined by the current look and feel).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @param border     the <code>Border</code> object to add the title to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @param title      a <code>String</code> containing the text of the title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * @return the <code>TitledBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    public static TitledBorder createTitledBorder(Border border,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                                                   String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        return new TitledBorder(border, title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * Adds a title to an existing border, with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * positioning and using the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * font and text color (determined by the current look and feel).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @param border      the <code>Border</code> object to add the title to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @param title       a <code>String</code> containing the text of the title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @param titleJustification  an integer specifying the justification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *        of the title -- one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     *<li><code>TitledBorder.LEFT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *<li><code>TitledBorder.CENTER</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *<li><code>TitledBorder.RIGHT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *<li><code>TitledBorder.LEADING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *<li><code>TitledBorder.TRAILING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @param titlePosition       an integer specifying the vertical position of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *        the text in relation to the border -- one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *<li><code> TitledBorder.ABOVE_TOP</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *<li><code>TitledBorder.TOP</code> (sitting on the top line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     *<li><code>TitledBorder.BELOW_TOP</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *<li><code>TitledBorder.ABOVE_BOTTOM</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *<li><code>TitledBorder.BELOW_BOTTOM</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     *</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @return the <code>TitledBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public static TitledBorder createTitledBorder(Border border,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                        String title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                        int titleJustification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                        int titlePosition)      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        return new TitledBorder(border, title, titleJustification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                        titlePosition);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Adds a title to an existing border, with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * positioning and font, and using the default text color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * (determined by the current look and feel).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @param border      the <code>Border</code> object to add the title to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @param title       a <code>String</code> containing the text of the title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @param titleJustification  an integer specifying the justification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *        of the title -- one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *<li><code>TitledBorder.LEFT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *<li><code>TitledBorder.CENTER</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *<li><code>TitledBorder.RIGHT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *<li><code>TitledBorder.LEADING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *<li><code>TitledBorder.TRAILING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @param titlePosition       an integer specifying the vertical position of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *        the text in relation to the border -- one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *<li><code> TitledBorder.ABOVE_TOP</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *<li><code>TitledBorder.TOP</code> (sitting on the top line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *<li><code>TitledBorder.BELOW_TOP</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *<li><code>TitledBorder.ABOVE_BOTTOM</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     *<li><code>TitledBorder.BELOW_BOTTOM</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     *</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @param titleFont           a Font object specifying the title font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @return the TitledBorder object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    public static TitledBorder createTitledBorder(Border border,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                        String title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                        int titleJustification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                        int titlePosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                        Font titleFont) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        return new TitledBorder(border, title, titleJustification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                        titlePosition, titleFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * Adds a title to an existing border, with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * positioning, font and color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @param border      the <code>Border</code> object to add the title to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @param title       a <code>String</code> containing the text of the title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @param titleJustification  an integer specifying the justification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *        of the title -- one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *<li><code>TitledBorder.LEFT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *<li><code>TitledBorder.CENTER</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *<li><code>TitledBorder.RIGHT</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *<li><code>TitledBorder.LEADING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *<li><code>TitledBorder.TRAILING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @param titlePosition       an integer specifying the vertical position of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *        the text in relation to the border -- one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *<li><code> TitledBorder.ABOVE_TOP</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *<li><code>TitledBorder.TOP</code> (sitting on the top line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *<li><code>TitledBorder.BELOW_TOP</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *<li><code>TitledBorder.ABOVE_BOTTOM</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *<li><code>TitledBorder.BELOW_BOTTOM</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *</ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @param titleFont   a <code>Font</code> object specifying the title font
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * @param titleColor  a <code>Color</code> object specifying the title color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * @return the <code>TitledBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    public static TitledBorder createTitledBorder(Border border,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                        String title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                        int titleJustification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                        int titlePosition,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                        Font titleFont,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                        Color titleColor)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        return new TitledBorder(border, title, titleJustification,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                        titlePosition, titleFont, titleColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
//// EmptyBorder ///////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    final static Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * Creates an empty border that takes up no space. (The width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * of the top, bottom, left, and right sides are all zero.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    public static Border createEmptyBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        return emptyBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * Creates an empty border that takes up space but which does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * no drawing, specifying the width of the top, left, bottom, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * right sides.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @param top     an integer specifying the width of the top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     *                  in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @param left    an integer specifying the width of the left side,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *                  in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @param bottom  an integer specifying the width of the bottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *                  in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @param right   an integer specifying the width of the right side,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *                  in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * @return the <code>Border</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    public static Border createEmptyBorder(int top, int left,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                                                int bottom, int right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        return new EmptyBorder(top, left, bottom, right);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
//// CompoundBorder ////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * Creates a compound border with a <code>null</code> inside edge and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * <code>null</code> outside edge.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @return the <code>CompoundBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    public static CompoundBorder createCompoundBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        return new CompoundBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * Creates a compound border specifying the border objects to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * for the outside and inside edges.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * @param outsideBorder  a <code>Border</code> object for the outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     *                          edge of the compound border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * @param insideBorder   a <code>Border</code> object for the inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     *                          edge of the compound border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * @return the <code>CompoundBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public static CompoundBorder createCompoundBorder(Border outsideBorder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                                                Border insideBorder) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        return new CompoundBorder(outsideBorder, insideBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
//// MatteBorder ////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * Creates a matte-look border using a solid color. (The difference between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * this border and a line border is that you can specify the individual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * border dimensions.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @param top     an integer specifying the width of the top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @param left    an integer specifying the width of the left side,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @param bottom  an integer specifying the width of the right side,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @param right   an integer specifying the width of the bottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @param color   a <code>Color</code> to use for the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * @return the <code>MatteBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                                                Color color) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        return new MatteBorder(top, left, bottom, right, color);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * Creates a matte-look border that consists of multiple tiles of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * specified icon. Multiple copies of the icon are placed side-by-side
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * to fill up the border area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * Note:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * If the icon doesn't load, the border area is painted gray.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @param top     an integer specifying the width of the top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @param left    an integer specifying the width of the left side,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @param bottom  an integer specifying the width of the right side,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * @param right   an integer specifying the width of the bottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     *                          in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * @param tileIcon  the <code>Icon</code> object used for the border tiles
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * @return the <code>MatteBorder</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                                Icon tileIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        return new MatteBorder(top, left, bottom, right, tileIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
7006
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   638
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   639
//// StrokeBorder //////////////////////////////////////////////////////////////
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   640
////////////////////////////////////////////////////////////////////////////////
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   641
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   642
    /**
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   643
     * Creates a border of the specified {@code stroke}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   644
     * The component's foreground color will be used to render the border.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   645
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   646
     * @param stroke  the {@link BasicStroke} object used to stroke a shape
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   647
     * @return the {@code Border} object
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   648
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   649
     * @throws NullPointerException if the specified {@code stroke} is {@code null}
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   650
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   651
     * @since 1.7
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   652
     */
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   653
    public static Border createStrokeBorder(BasicStroke stroke) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   654
        return new StrokeBorder(stroke);
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   655
    }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   656
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   657
    /**
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   658
     * Creates a border of the specified {@code stroke} and {@code paint}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   659
     * If the specified {@code paint} is {@code null},
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   660
     * the component's foreground color will be used to render the border.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   661
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   662
     * @param stroke  the {@link BasicStroke} object used to stroke a shape
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   663
     * @param paint   the {@link Paint} object used to generate a color
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   664
     * @return the {@code Border} object
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   665
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   666
     * @throws NullPointerException if the specified {@code stroke} is {@code null}
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   667
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   668
     * @since 1.7
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   669
     */
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   670
    public static Border createStrokeBorder(BasicStroke stroke, Paint paint) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   671
        return new StrokeBorder(stroke, paint);
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   672
    }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   673
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   674
//// DashedBorder //////////////////////////////////////////////////////////////
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   675
////////////////////////////////////////////////////////////////////////////////
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   676
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   677
    private static Border sharedDashedBorder;
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   678
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   679
    /**
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   680
     * Creates a dashed border of the specified {@code paint}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   681
     * If the specified {@code paint} is {@code null},
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   682
     * the component's foreground color will be used to render the border.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   683
     * The width of a dash line is equal to {@code 1}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   684
     * The relative length of a dash line and
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   685
     * the relative spacing between dash lines are equal to {@code 1}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   686
     * A dash line is not rounded.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   687
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   688
     * @param paint  the {@link Paint} object used to generate a color
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   689
     * @return the {@code Border} object
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   690
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   691
     * @since 1.7
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   692
     */
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   693
    public static Border createDashedBorder(Paint paint) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   694
        return createDashedBorder(paint, 1.0f, 1.0f, 1.0f, false);
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   695
    }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   696
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   697
    /**
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   698
     * Creates a dashed border of the specified {@code paint},
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   699
     * relative {@code length}, and relative {@code spacing}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   700
     * If the specified {@code paint} is {@code null},
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   701
     * the component's foreground color will be used to render the border.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   702
     * The width of a dash line is equal to {@code 1}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   703
     * A dash line is not rounded.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   704
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   705
     * @param paint    the {@link Paint} object used to generate a color
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   706
     * @param length   the relative length of a dash line
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   707
     * @param spacing  the relative spacing between dash lines
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   708
     * @return the {@code Border} object
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   709
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   710
     * @throws IllegalArgumentException if the specified {@code length} is less than {@code 1}, or
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   711
     *                                  if the specified {@code spacing} is less than {@code 0}
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   712
     * @since 1.7
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   713
     */
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   714
    public static Border createDashedBorder(Paint paint, float length, float spacing) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   715
        return createDashedBorder(paint, 1.0f, length, spacing, false);
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   716
    }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   717
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   718
    /**
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   719
     * Creates a dashed border of the specified {@code paint}, {@code thickness},
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   720
     * line shape, relative {@code length}, and relative {@code spacing}.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   721
     * If the specified {@code paint} is {@code null},
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   722
     * the component's foreground color will be used to render the border.
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   723
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   724
     * @param paint      the {@link Paint} object used to generate a color
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   725
     * @param thickness  the width of a dash line
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   726
     * @param length     the relative length of a dash line
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   727
     * @param spacing    the relative spacing between dash lines
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   728
     * @param rounded    whether or not line ends should be round
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   729
     * @return the {@code Border} object
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   730
     *
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   731
     * @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   732
     *                                  if the specified {@code length} is less than {@code 1}, or
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   733
     *                                  if the specified {@code spacing} is less than {@code 0}
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   734
     * @since 1.7
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   735
     */
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   736
    public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   737
        boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   738
        if (shared && (sharedDashedBorder != null)) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   739
            return sharedDashedBorder;
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   740
        }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   741
        if (thickness < 1.0f) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   742
            throw new IllegalArgumentException("thickness is less than 1");
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   743
        }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   744
        if (length < 1.0f) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   745
            throw new IllegalArgumentException("length is less than 1");
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   746
        }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   747
        if (spacing < 0.0f) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   748
            throw new IllegalArgumentException("spacing is less than 0");
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   749
        }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   750
        int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   751
        int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   752
        float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   753
        Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   754
        if (shared) {
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   755
            sharedDashedBorder = border;
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   756
        }
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   757
        return border;
05505fff1342 4358979: javax.swing.border should have a DashedBorder
malenkov
parents: 5765
diff changeset
   758
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
}