jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicBorders.java
author weijun
Thu, 11 Dec 2014 15:19:12 +0800
changeset 28228 be83f404724d
parent 25859 3317bb8137f4
child 29507 f16389ada5f3
permissions -rw-r--r--
8067207: Replace concat String to append in StringBuilder parameters (client) Reviewed-by: serb Contributed-by: Otavio Santana <otaviojava@java.net>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
     2
 * Copyright (c) 1997, 2014, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.basic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.text.JTextComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 6510
diff changeset
    41
 * Factory object that can vend Borders appropriate for the basic L &amp; F.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author Amy Fowler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class BasicBorders {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    48
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    49
     * Returns a border instance for a {@code JButton}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    50
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    51
     * @return a border instance for a {@code JButton}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    52
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public static Border getButtonBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        Border buttonBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                           new BasicBorders.ButtonBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                                           table.getColor("Button.shadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                                           table.getColor("Button.darkShadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                           table.getColor("Button.light"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                                           table.getColor("Button.highlight")),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                                     new MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        return buttonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    65
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    66
     * Returns a border instance for a {@code JRadioButton}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    67
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    68
     * @return a border instance for a {@code JRadioButton}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    69
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static Border getRadioButtonBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        Border radioButtonBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                           new BasicBorders.RadioButtonBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                                           table.getColor("RadioButton.shadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                           table.getColor("RadioButton.darkShadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                           table.getColor("RadioButton.light"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                           table.getColor("RadioButton.highlight")),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                     new MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return radioButtonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    82
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    83
     * Returns a border instance for a {@code JToggleButton}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    84
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    85
     * @return a border instance for a {@code JToggleButton}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    86
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public static Border getToggleButtonBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        Border toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                                     new BasicBorders.ToggleButtonBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                           table.getColor("ToggleButton.shadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                                           table.getColor("ToggleButton.darkShadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                                           table.getColor("ToggleButton.light"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                                           table.getColor("ToggleButton.highlight")),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                                     new MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return toggleButtonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
    99
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   100
     * Returns a border instance for a {@code JMenuBar}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   101
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   102
     * @return a border instance for a {@code JMenuBar}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   103
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public static Border getMenuBarBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        Border menuBarBorder = new BasicBorders.MenuBarBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                                        table.getColor("MenuBar.shadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                        table.getColor("MenuBar.highlight")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                   );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return menuBarBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   113
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   114
     * Returns a border instance for a {@code JSplitPane}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   115
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   116
     * @return a border instance for a {@code JSplitPane}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   117
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public static Border getSplitPaneBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        Border splitPaneBorder = new BasicBorders.SplitPaneBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                                     table.getColor("SplitPane.highlight"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                                     table.getColor("SplitPane.darkShadow"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return splitPaneBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   127
     * Returns a border instance for a {@code JSplitPane} divider.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   128
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   129
     * @return a border instance for a {@code JSplitPane} divider
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public static Border getSplitPaneDividerBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        Border splitPaneBorder = new BasicBorders.SplitPaneDividerBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                     table.getColor("SplitPane.highlight"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                     table.getColor("SplitPane.darkShadow"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return splitPaneBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   140
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   141
     * Returns a border instance for a {@code JTextField}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   142
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   143
     * @return a border instance for a {@code JTextField}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   144
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public static Border getTextFieldBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        Border textFieldBorder = new BasicBorders.FieldBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                                           table.getColor("TextField.shadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                           table.getColor("TextField.darkShadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                           table.getColor("TextField.light"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                           table.getColor("TextField.highlight"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return textFieldBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   155
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   156
     * Returns a border instance for a {@code JProgressBar}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   157
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   158
     * @return a border instance for a {@code JProgressBar}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   159
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public static Border getProgressBarBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        Border progressBarBorder = new BorderUIResource.LineBorderUIResource(Color.green, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        return progressBarBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   166
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   167
     * Returns a border instance for a {@code JInternalFrame}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   168
     *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   169
     * @return a border instance for a {@code JInternalFrame}
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   170
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public static Border getInternalFrameBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        UIDefaults table = UIManager.getLookAndFeelDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        Border internalFrameBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                new BevelBorder(BevelBorder.RAISED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                        table.getColor("InternalFrame.borderLight"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                                        table.getColor("InternalFrame.borderHighlight"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                        table.getColor("InternalFrame.borderDarkShadow"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                                        table.getColor("InternalFrame.borderShadow")),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                BorderFactory.createLineBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                        table.getColor("InternalFrame.borderColor"), 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return internalFrameBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Special thin border for rollover toolbar buttons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   189
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public static class RolloverButtonBorder extends ButtonBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   192
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   193
         * Constructs a new instance of a {@code RolloverButtonBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   194
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   195
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   196
         * @param darkShadow a color of dark shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   197
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   198
         * @param lightHighlight a color of light highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   199
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        public RolloverButtonBorder(Color shadow, Color darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                  Color highlight, Color lightHighlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            super(shadow, darkShadow, highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            AbstractButton b = (AbstractButton) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            Color shade = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            Component p = b.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            if (p != null && p.getBackground().equals(shadow)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                shade = darkShadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            if ((model.isRollover() && !(model.isPressed() && !model.isArmed())) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                model.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                if (model.isPressed() && model.isArmed() || model.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    // Draw the pressd button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                    g.setColor(shade);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    g.drawRect(0, 0, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    g.setColor(lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    g.drawLine(w-1, 0, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                    g.drawLine(0, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                    // Draw a rollover button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    g.setColor(lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    g.drawRect(0, 0, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                    g.setColor(shade);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                    g.drawLine(w-1, 0, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    g.drawLine(0, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                g.translate(-x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * A border which is like a Margin border but it will only honor the margin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * if the margin has been explicitly set by the developer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Note: This is identical to the package private class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * MetalBorders.RolloverMarginBorder and should probably be consolidated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   250
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    static class RolloverMarginBorder extends EmptyBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        public RolloverMarginBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            super(3,3,3,3); // hardcoded margin for JLF requirements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            Insets margin = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            if (c instanceof AbstractButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                margin = ((AbstractButton)c).getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            if (margin == null || margin instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                // default margin so replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                insets.left = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                insets.top = top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                insets.right = right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                insets.bottom = bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                // Margin which has been explicitly set by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                insets.left = margin.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                insets.top = margin.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                insets.right = margin.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                insets.bottom = margin.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   280
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   281
     * Draws a border around a button.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   282
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   283
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
   public static class ButtonBorder extends AbstractBorder implements UIResource {
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   285
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   286
         * The color of shadow.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   287
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        protected Color shadow;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   289
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   290
         * The color of dark shadow.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   291
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        protected Color darkShadow;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   293
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   294
         * The color of highlight.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   295
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        protected Color highlight;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   297
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   298
         * The color of light highlight.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   299
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        protected Color lightHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   302
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   303
         * Constructs a new instance of a {@code ButtonBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   304
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   305
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   306
         * @param darkShadow a color of dark shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   307
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   308
         * @param lightHighlight a color of light highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   309
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        public ButtonBorder(Color shadow, Color darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                            Color highlight, Color lightHighlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            this.shadow = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            this.darkShadow = darkShadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            this.highlight = highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            this.lightHighlight = lightHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                            int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            boolean isPressed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            boolean isDefault = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            if (c instanceof AbstractButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                AbstractButton b = (AbstractButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                isPressed = model.isPressed() && model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                if (c instanceof JButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    isDefault = ((JButton)c).isDefaultButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            BasicGraphicsUtils.drawBezel(g, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                   isPressed, isDefault, shadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                                   darkShadow, highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        public Insets getBorderInsets(Component c, Insets insets)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            // leave room for default visual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            insets.set(2, 3, 3, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   346
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   347
     * Draws the border around a toggle button.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   348
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   349
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public static class ToggleButtonBorder extends ButtonBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   352
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   353
         * Constructs a new instance of a {@code ToggleButtonBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   354
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   355
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   356
         * @param darkShadow a color of dark shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   357
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   358
         * @param lightHighlight a color of light highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   359
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        public ToggleButtonBorder(Color shadow, Color darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                                  Color highlight, Color lightHighlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            super(shadow, darkShadow, highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                                int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                BasicGraphicsUtils.drawBezel(g, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                                             false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                                             shadow, darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                                             highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        public Insets getBorderInsets(Component c, Insets insets)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            insets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   379
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   380
     * Draws the border around a radio button.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   381
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   382
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public static class RadioButtonBorder extends ButtonBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   385
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   386
         * Constructs a new instance of a {@code RadioButtonBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   387
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   388
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   389
         * @param darkShadow a color of dark shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   390
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   391
         * @param lightHighlight a color of light highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   392
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        public RadioButtonBorder(Color shadow, Color darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                 Color highlight, Color lightHighlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            super(shadow, darkShadow, highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            if (c instanceof AbstractButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                AbstractButton b = (AbstractButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                if (model.isArmed() && model.isPressed() || model.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                    BasicGraphicsUtils.drawLoweredBezel(g, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                                                        shadow, darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                                                        highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                    BasicGraphicsUtils.drawBezel(g, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                                               false, b.isFocusPainted() && b.hasFocus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                                                 shadow, darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                                 highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                BasicGraphicsUtils.drawBezel(g, x, y, width, height, false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                                             shadow, darkShadow, highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        public Insets getBorderInsets(Component c, Insets insets)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            insets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   427
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   428
     * Draws the border around a menu bar.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   429
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   430
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    public static class MenuBarBorder extends AbstractBorder implements UIResource {
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   432
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   433
         * The color of shadow.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   434
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        private Color shadow;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   436
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   437
         * The color of highlight.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   438
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        private Color highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   441
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   442
         * Constructs a new instance of a {@code MenuBarBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   443
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   444
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   445
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   446
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        public MenuBarBorder(Color shadow, Color highlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            this.shadow = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            this.highlight = highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            Color oldColor = g.getColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            g.drawLine(0, height-2, width, height-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            g.drawLine(0, height-1, width, height-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            g.translate(-x,-y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            g.setColor(oldColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        public Insets getBorderInsets(Component c, Insets insets)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            insets.set(0, 0, 2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   469
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   470
     * Draws the border around components which support margins.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   471
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   472
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public static class MarginBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        public Insets getBorderInsets(Component c, Insets insets)       {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            Insets margin = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            // Ideally we'd have an interface defined for classes which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            // support margins (to avoid this hackery), but we've
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            // decided against it for simplicity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
           if (c instanceof AbstractButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
               AbstractButton b = (AbstractButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
               margin = b.getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
           } else if (c instanceof JToolBar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
               JToolBar t = (JToolBar)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
               margin = t.getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
           } else if (c instanceof JTextComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
               JTextComponent t = (JTextComponent)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
               margin = t.getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
           insets.top = margin != null? margin.top : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
           insets.left = margin != null? margin.left : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
           insets.bottom = margin != null? margin.bottom : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
           insets.right = margin != null? margin.right : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
           return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   500
    /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   501
     * Draws the border around a field.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   502
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   503
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    public static class FieldBorder extends AbstractBorder implements UIResource {
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   505
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   506
         * The color of shadow.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   507
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        protected Color shadow;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   509
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   510
         * The color of dark shadow.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   511
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        protected Color darkShadow;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   513
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   514
         * The color of highlight.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   515
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        protected Color highlight;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   517
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   518
         * The color of light highlight.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   519
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        protected Color lightHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   522
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   523
         * Constructs a new instance of a {@code FieldBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   524
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   525
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   526
         * @param darkShadow a color of dark shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   527
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   528
         * @param lightHighlight a color of light highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   529
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        public FieldBorder(Color shadow, Color darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                           Color highlight, Color lightHighlight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            this.shadow = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            this.highlight = highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            this.darkShadow = darkShadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            this.lightHighlight = lightHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                            int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            BasicGraphicsUtils.drawEtchedRect(g, x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                              shadow, darkShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                              highlight, lightHighlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            Insets margin = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            if (c instanceof JTextComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                margin = ((JTextComponent)c).getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            insets.top = margin != null? 2+margin.top : 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            insets.left = margin != null? 2+margin.left : 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            insets.bottom = margin != null? 2+margin.bottom : 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            insets.right = margin != null? 2+margin.right : 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * Draws the border around the divider in a splitpane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * (when BasicSplitPaneUI is used). To get the appropriate effect, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * needs to be used with a SplitPaneBorder.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    static class SplitPaneDividerBorder implements Border, UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        Color highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        Color shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        SplitPaneDividerBorder(Color highlight, Color shadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            this.highlight = highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            this.shadow = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                                int width, int height) {
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   576
            if (!(c instanceof BasicSplitPaneDivider)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   577
                return;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   578
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            Component          child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            Rectangle          cBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            JSplitPane         splitPane = ((BasicSplitPaneDivider)c).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                                         getBasicSplitPaneUI().getSplitPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            Dimension          size = c.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            child = splitPane.getLeftComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            // This is needed for the space between the divider and end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            // splitpane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            g.setColor(c.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            g.drawRect(x, y, width - 1, height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            if(splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                    g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                    g.drawLine(0, 0, 0, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                child = splitPane.getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                    g.drawLine(size.width - 1, 0, size.width - 1, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                    g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                    g.drawLine(0, 0, size.width, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                child = splitPane.getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                    g.drawLine(0, size.height - 1, size.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                               size.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        public Insets getBorderInsets(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            Insets insets = new Insets(0,0,0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            if (c instanceof BasicSplitPaneDivider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                BasicSplitPaneUI bspui = ((BasicSplitPaneDivider)c).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                                         getBasicSplitPaneUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                if (bspui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                    JSplitPane splitPane = bspui.getSplitPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                    if (splitPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                        if (splitPane.getOrientation() ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                            JSplitPane.HORIZONTAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                            insets.top = insets.bottom = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                            insets.left = insets.right = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                        // VERTICAL_SPLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                        insets.top = insets.bottom = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                        insets.left = insets.right = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                        return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            insets.top = insets.bottom = insets.left = insets.right = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        public boolean isBorderOpaque() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    /**
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20169
diff changeset
   644
     * Draws the border around the splitpane. To work correctly you should
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * also install a border on the divider (property SplitPaneDivider.border).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    public static class SplitPaneBorder implements Border, UIResource {
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   648
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   649
         * The color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   650
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        protected Color highlight;
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   652
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   653
         * The color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   654
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        protected Color shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
25765
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   657
        /**
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   658
         * Constructs a new instance of a {@code SplitPaneBorder}.
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   659
         *
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   660
         * @param highlight a color of highlight
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   661
         * @param shadow a color of shadow
88051e6ecdc7 8049808: Fix doclint warnings from javax.swing.plaf.basic package, 3 of 7
aeremeev
parents: 23697
diff changeset
   662
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        public SplitPaneBorder(Color highlight, Color shadow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            this.highlight = highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            this.shadow = shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                                int width, int height) {
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   670
            if (!(c instanceof JSplitPane)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   671
                return;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   672
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            // The only tricky part with this border is that the divider is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            // not positioned at the top (for horizontal) or left (for vert),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            // so this border draws to where the divider is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            // -----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            // |xxxxxxx xxxxxxx|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            // |x     ---     x|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            // |x     | |     x|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            // |x     |D|     x|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            // |x     | |     x|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            // |x     ---     x|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            // |xxxxxxx xxxxxxx|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            // -----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            // The above shows (rather excessively) what this looks like for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            // a horizontal orientation. This border then draws the x's, with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            // the SplitPaneDividerBorder drawing its own border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            Component          child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            Rectangle          cBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            JSplitPane splitPane = (JSplitPane)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            child = splitPane.getLeftComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            // This is needed for the space between the divider and end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            // splitpane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            g.setColor(c.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            g.drawRect(x, y, width - 1, height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            if(splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                    cBounds = child.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    g.drawLine(0, 0, cBounds.width + 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    g.drawLine(0, 1, 0, cBounds.height + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                    g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                    g.drawLine(0, cBounds.height + 1, cBounds.width + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                               cBounds.height + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                child = splitPane.getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                    cBounds = child.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                    int             maxX = cBounds.x + cBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                    int             maxY = cBounds.y + cBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    g.drawLine(cBounds.x - 1, 0, maxX, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                    g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                    g.drawLine(cBounds.x - 1, maxY, maxX, maxY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                    g.drawLine(maxX, 0, maxX, maxY + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                    cBounds = child.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                    g.drawLine(0, 0, cBounds.width + 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                    g.drawLine(0, 1, 0, cBounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                    g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                    g.drawLine(1 + cBounds.width, 0, 1 + cBounds.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                               cBounds.height + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                    g.drawLine(0, cBounds.height + 1, 0, cBounds.height + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                child = splitPane.getRightComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                if(child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                    cBounds = child.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    int             maxX = cBounds.x + cBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                    int             maxY = cBounds.y + cBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                    g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                    g.drawLine(0, cBounds.y - 1, 0, maxY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                    g.drawLine(maxX, cBounds.y - 1, maxX, cBounds.y - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                    g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                    g.drawLine(0, maxY, cBounds.width + 1, maxY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                    g.drawLine(maxX, cBounds.y, maxX, maxY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        public Insets getBorderInsets(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            return new Insets(1, 1, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        public boolean isBorderOpaque() { return true; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
}