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