jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java
author yan
Mon, 30 Jun 2014 16:32:36 +0400
changeset 25178 dbab904451e9
parent 23697 e556a715949f
permissions -rw-r--r--
8046434: Fix doclint warnings from javax.swing.plaf.metal package Reviewed-by: alexsch Contributed-by: Andrei Eremeev <andrei.eremeev@oracle.com>
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) 1998, 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.metal;
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.plaf.basic.BasicBorders;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.text.JTextComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.Dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.Frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.Window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.swing.StringUIClientPropertyKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 6510
diff changeset
    46
 * Factory object that can vend Borders appropriate for the metal L &amp; F.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class MetalBorders {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Client property indicating the button shouldn't provide a rollover
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * indicator. Only used with the Ocean theme.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    static Object NO_BUTTON_ROLLOVER =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        new StringUIClientPropertyKey("NoButtonRollover");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    59
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    60
     * The class represents the 3D border.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    61
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
    62
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public static class Flush3DBorder extends AbstractBorder implements UIResource{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                          int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            if (c.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                MetalUtils.drawFlush3DBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                MetalUtils.drawDisabledBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            newInsets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    79
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    80
     * The class represents the border of a {@code JButton}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    81
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
    82
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public static class ButtonBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    85
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    86
         * The border insets.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    87
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        protected static Insets borderInsets = new Insets( 3, 3, 3, 3 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
    91
            if (!(c instanceof AbstractButton)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
    92
                return;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
    93
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                paintOceanBorder(c, g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            AbstractButton button = (AbstractButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            ButtonModel model = button.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            if ( model.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                boolean isPressed = model.isPressed() && model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                boolean isDefault = (button instanceof JButton && ((JButton)button).isDefaultButton());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                if (isPressed && isDefault) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    MetalUtils.drawDefaultButtonPressedBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                } else if (isPressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                    MetalUtils.drawPressed3DBorder( g, x, y, w, h );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                } else if (isDefault) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                    MetalUtils.drawDefaultButtonBorder( g, x, y, w, h, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                    MetalUtils.drawButtonBorder( g, x, y, w, h, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            } else { // disabled state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                MetalUtils.drawDisabledBorder( g, x, y, w-1, h-1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        private void paintOceanBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                      int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            AbstractButton button = (AbstractButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            ButtonModel model = ((AbstractButton)c).getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            g.translate(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            if (MetalUtils.isToolBarButton(button)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                if (model.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    if (model.isPressed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                        g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                        g.fillRect(1, h - 1, w - 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                        g.fillRect(w - 1, 1, 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                        g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                        g.drawRect(0, 0, w - 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                        g.fillRect(1, 1, w - 3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    else if (model.isSelected() || model.isRollover()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                        g.fillRect(1, h - 1, w - 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                        g.fillRect(w - 1, 1, 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                        g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                        g.drawRect(0, 0, w - 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                        g.setColor(MetalLookAndFeel.getWhite());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                        g.drawRect(1, 1, w - 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                        g.setColor(UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                "Button.toolBarBorderBackground"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                        g.drawRect(0, 0, w - 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                   g.setColor(UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                           "Button.disabledToolBarBorderBackground"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                   g.drawRect(0, 0, w - 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            else if (model.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                boolean pressed = model.isPressed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                boolean armed = model.isArmed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                if ((c instanceof JButton) && ((JButton)c).isDefaultButton()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    g.drawRect(1, 1, w - 3, h - 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                else if (pressed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    g.fillRect(0, 0, w, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    g.fillRect(0, 2, 2, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    g.fillRect(w - 1, 1, 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    g.fillRect(1, h - 1, w - 2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                else if (model.isRollover() && button.getClientProperty(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                               NO_BUTTON_ROLLOVER) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    g.setColor(MetalLookAndFeel.getPrimaryControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    g.drawRect(2, 2, w - 5, h - 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    g.drawRect(1, 1, w - 3, h - 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                if ((c instanceof JButton) && ((JButton)c).isDefaultButton()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    g.drawRect(1, 1, w - 3, h - 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            newInsets.set(3, 3, 3, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   200
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   201
     * The class represents the border of a {@code JInternalFrame}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   202
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   203
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public static class InternalFrameBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        private static final int corner = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                          int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            Color background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            Color highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            Color shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            if (c instanceof JInternalFrame && ((JInternalFrame)c).isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                background = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                highlight = MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                shadow = MetalLookAndFeel.getPrimaryControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                background = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                highlight = MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                shadow = MetalLookAndFeel.getControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
              g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
              // Draw outermost lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
              g.drawLine( 1, 0, w-2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
              g.drawLine( 0, 1, 0, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
              g.drawLine( w-1, 1, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
              g.drawLine( 1, h-1, w-2, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
              // Draw the bulk of the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
              for (int i = 1; i < 5; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                  g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
              if (c instanceof JInternalFrame &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                               ((JInternalFrame)c).isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                  g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                  // Draw the Long highlight lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                  g.drawLine( corner+1, 3, w-corner, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                  g.drawLine( 3, corner+1, 3, h-corner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                  g.drawLine( w-2, corner+1, w-2, h-corner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                  g.drawLine( corner+1, h-2, w-corner, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                  g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                  // Draw the Long shadow lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                  g.drawLine( corner, 2, w-corner-1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                  g.drawLine( 2, corner, 2, h-corner-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                  g.drawLine( w-3, corner, w-3, h-corner-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                  g.drawLine( corner, h-3, w-corner-1, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
          public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
              newInsets.set(5, 5, 5, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
              return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Border for a Frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   265
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    static class FrameBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        private static final int corner = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            Color background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            Color highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            Color shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            Window window = SwingUtilities.getWindowAncestor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            if (window != null && window.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                background = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                highlight = MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                shadow = MetalLookAndFeel.getPrimaryControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                background = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                highlight = MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                shadow = MetalLookAndFeel.getControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            // Draw outermost lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            g.drawLine( x+1, y+0, x+w-2, y+0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            g.drawLine( x+0, y+1, x+0, y +h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            g.drawLine( x+w-1, y+1, x+w-1, y+h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            g.drawLine( x+1, y+h-1, x+w-2, y+h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            // Draw the bulk of the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            for (int i = 1; i < 5; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            if ((window instanceof Frame) && ((Frame) window).isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                // Draw the Long highlight lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                g.drawLine( corner+1, 3, w-corner, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                g.drawLine( 3, corner+1, 3, h-corner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                g.drawLine( w-2, corner+1, w-2, h-corner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                g.drawLine( corner+1, h-2, w-corner, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                // Draw the Long shadow lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                g.drawLine( corner, 2, w-corner-1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                g.drawLine( 2, corner, 2, h-corner-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                g.drawLine( w-3, corner, w-3, h-corner-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                g.drawLine( corner, h-3, w-corner-1, h-3);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        public Insets getBorderInsets(Component c, Insets newInsets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            newInsets.set(5, 5, 5, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Border for a Frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   328
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    static class DialogBorder extends AbstractBorder implements UIResource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        private static final int corner = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        protected Color getActiveBackground()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            return MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        protected Color getActiveHighlight()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            return MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        protected Color getActiveShadow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            return MetalLookAndFeel.getPrimaryControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        protected Color getInactiveBackground()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            return MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        protected Color getInactiveHighlight()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            return MetalLookAndFeel.getControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        protected Color getInactiveShadow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            return MetalLookAndFeel.getControlInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            Color background;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            Color highlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            Color shadow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            Window window = SwingUtilities.getWindowAncestor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (window != null && window.isActive()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                background = getActiveBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                highlight = getActiveHighlight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                shadow = getActiveShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                background = getInactiveBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                highlight = getInactiveHighlight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                shadow = getInactiveShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            // Draw outermost lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            g.drawLine( x + 1, y + 0, x + w-2, y + 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            g.drawLine( x + 0, y + 1, x + 0, y + h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            g.drawLine( x + w - 1, y + 1, x + w - 1, y + h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            g.drawLine( x + 1, y + h - 1, x + w - 2, y + h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            // Draw the bulk of the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            for (int i = 1; i < 5; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            if ((window instanceof Dialog) && ((Dialog) window).isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                g.setColor(highlight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                // Draw the Long highlight lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                g.drawLine( corner+1, 3, w-corner, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                g.drawLine( 3, corner+1, 3, h-corner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                g.drawLine( w-2, corner+1, w-2, h-corner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                g.drawLine( corner+1, h-2, w-corner, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                g.setColor(shadow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                // Draw the Long shadow lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                g.drawLine( corner, 2, w-corner-1, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                g.drawLine( 2, corner, 2, h-corner-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                g.drawLine( w-3, corner, w-3, h-corner-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                g.drawLine( corner, h-3, w-corner-1, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        public Insets getBorderInsets(Component c, Insets newInsets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            newInsets.set(5, 5, 5, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            return newInsets;
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * Border for an Error Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   422
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    static class ErrorDialogBorder extends DialogBorder implements UIResource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        protected Color getActiveBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            return UIManager.getColor("OptionPane.errorDialog.border.background");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * Border for a QuestionDialog.  Also used for a JFileChooser and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * JColorChooser..
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   436
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    static class QuestionDialogBorder extends DialogBorder implements UIResource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        protected Color getActiveBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            return UIManager.getColor("OptionPane.questionDialog.border.background");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * Border for a Warning Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   449
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    static class WarningDialogBorder extends DialogBorder implements UIResource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        protected Color getActiveBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            return UIManager.getColor("OptionPane.warningDialog.border.background");
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * Border for a Palette.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   462
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    public static class PaletteBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        int titleHeight = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            g.translate(x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            g.drawLine(0, 1, 0, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            g.drawLine(1, h-1, w-2, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            g.drawLine(w-1,  1, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            g.drawLine( 1, 0, w-2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            g.drawRect(1,1, w-3, h-3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            g.translate(-x,-y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            newInsets.set(1, 1, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   485
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   486
     * The class represents the border of an option dialog.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   487
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   488
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    public static class OptionDialogBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        int titleHeight = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            g.translate(x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            int messageType = JOptionPane.PLAIN_MESSAGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            if (c instanceof JInternalFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                Object obj = ((JInternalFrame) c).getClientProperty(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                              "JInternalFrame.messageType");
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   500
                if (obj instanceof Integer) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   501
                    messageType = (Integer) obj;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            Color borderColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            switch (messageType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            case(JOptionPane.ERROR_MESSAGE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                borderColor = UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    "OptionPane.errorDialog.border.background");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            case(JOptionPane.QUESTION_MESSAGE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                borderColor = UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                    "OptionPane.questionDialog.border.background");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            case(JOptionPane.WARNING_MESSAGE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                borderColor = UIManager.getColor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    "OptionPane.warningDialog.border.background");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            case(JOptionPane.INFORMATION_MESSAGE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            case(JOptionPane.PLAIN_MESSAGE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                borderColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            g.setColor(borderColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
              // Draw outermost lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
              g.drawLine( 1, 0, w-2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
              g.drawLine( 0, 1, 0, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
              g.drawLine( w-1, 1, w-1, h-2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
              g.drawLine( 1, h-1, w-2, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
              // Draw the bulk of the border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
              for (int i = 1; i < 3; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                  g.drawRect(i, i, w-(i*2)-1, h-(i*2)-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            g.translate(-x,-y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            newInsets.set(3, 3, 3, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   550
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   551
     * The class represents the border of a {@code JMenuBar}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   552
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   553
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    public static class MenuBarBorder extends AbstractBorder implements UIResource {
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   555
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   556
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   557
         * The border insets.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   558
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        protected static Insets borderInsets = new Insets( 1, 0, 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                // Only paint a border if we're not next to a horizontal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                // toolbar
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   567
                if ((c instanceof JMenuBar) && !MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar)c)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                    g.setColor(MetalLookAndFeel.getControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                    g.drawLine(0, h - 2, w, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    g.setColor(UIManager.getColor("MenuBar.borderColor"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                    g.drawLine(0, h - 1, w, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                g.setColor( MetalLookAndFeel.getControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                g.drawLine( 0, h-1, w, h-1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            g.translate( -x, -y );
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
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                newInsets.set(0, 0, 2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                newInsets.set(1, 0, 1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   594
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   595
     * The class represents the border of a {@code JMenuItem}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   596
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   597
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    public static class MenuItemBorder extends AbstractBorder implements UIResource {
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   599
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   600
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   601
         * The border insets.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   602
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        protected static Insets borderInsets = new Insets( 2, 2, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   606
            if (!(c instanceof JMenuItem)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   607
                return;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   608
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            JMenuItem b = (JMenuItem) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            if ( c.getParent() instanceof JMenuBar ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                if ( model.isArmed() || model.isSelected() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                    g.setColor( MetalLookAndFeel.getControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                    g.drawLine( 0, 0, w - 2, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                    g.drawLine( 0, 0, 0, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                    g.drawLine( w - 2, 2, w - 2, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                    g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                    g.drawLine( w - 1, 1, w - 1, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                    g.setColor( MetalLookAndFeel.getMenuBackground() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                    g.drawLine( w - 1, 0, w - 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                if (  model.isArmed() || ( c instanceof JMenu && model.isSelected() ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                    g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                    g.drawLine( 0, 0, w - 1, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                    g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                    g.drawLine( 0, h - 1, w - 1, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                    g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                    g.drawLine( 0, 0, 0, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            newInsets.set(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   649
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   650
     * The class represents the border of a {@code JPopupMenu}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   651
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   652
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    public static class PopupMenuBorder extends AbstractBorder implements UIResource {
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   654
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   655
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   656
         * The border insets.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   657
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        protected static Insets borderInsets = new Insets( 3, 1, 2, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            g.drawRect( 0, 0, w - 1, h - 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            g.drawLine( 1, 1, w - 2, 1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            g.drawLine( 1, 2, 1, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            g.drawLine( 1, h - 2, 1, h - 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            newInsets.set(3, 1, 2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   681
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   682
     * The class represents the border of a rollover {@code Button}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   683
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   684
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    public static class RolloverButtonBorder extends ButtonBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            AbstractButton b = (AbstractButton) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            if ( model.isRollover() && !( model.isPressed() && !model.isArmed() ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                super.paintBorder( c, g, x, y, w, h );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * A border which is like a Margin border but it will only honor the margin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * if the margin has been explicitly set by the developer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * Note: This is identical to the package private class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * BasicBorders.RolloverMarginBorder and should probably be consolidated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   705
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    static class RolloverMarginBorder extends EmptyBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        public RolloverMarginBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            super(3,3,3,3); // hardcoded margin for JLF requirements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            Insets margin = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            if (c instanceof AbstractButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                margin = ((AbstractButton)c).getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            if (margin == null || margin instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                // default margin so replace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                insets.left = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                insets.top = top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                insets.right = right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                insets.bottom = bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                // Margin which has been explicitly set by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                insets.left = margin.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                insets.top = margin.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                insets.right = margin.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                insets.bottom = margin.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   735
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   736
     * The class represents the border of a {@code JToolBar}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   737
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   738
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    {
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   741
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   742
         * The instance of {@code MetalBumps}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   743
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        protected MetalBumps bumps = new MetalBumps( 10, 10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                                      MetalLookAndFeel.getControlHighlight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                                      MetalLookAndFeel.getControlDarkShadow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                                     UIManager.getColor("ToolBar.background"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        {
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   751
            if (!(c instanceof JToolBar)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   752
                return;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   753
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            if ( ((JToolBar) c).isFloatable() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                if ( ((JToolBar) c).getOrientation() == HORIZONTAL )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                    int shift = MetalLookAndFeel.usingOcean() ? -1 : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                    bumps.setBumpArea( 10, h - 4 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                    if( MetalUtils.isLeftToRight(c) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                        bumps.paintIcon( c, g, 2, 2 + shift );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                        bumps.paintIcon( c, g, w-12,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                                         2 + shift );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                else // vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                    bumps.setBumpArea( w - 4, 10 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                    bumps.paintIcon( c, g, 2, 2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            if (((JToolBar) c).getOrientation() == HORIZONTAL &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                               MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                g.setColor(MetalLookAndFeel.getControl());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                g.drawLine(0, h - 2, w, h - 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                g.setColor(UIManager.getColor("ToolBar.borderColor"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                g.drawLine(0, h - 1, w, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        public Insets getBorderInsets(Component c, Insets newInsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                newInsets.set(1, 2, 3, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                newInsets.top = newInsets.left = newInsets.bottom = newInsets.right = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   796
            if (!(c instanceof JToolBar)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   797
                return newInsets;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   798
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            if ( ((JToolBar) c).isFloatable() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                if ( ((JToolBar) c).getOrientation() == HORIZONTAL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                    if (c.getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                        newInsets.left = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                        newInsets.right = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                } else {// vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                    newInsets.top = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            Insets margin = ((JToolBar) c).getMargin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            if ( margin != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                newInsets.left   += margin.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                newInsets.top    += margin.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                newInsets.right  += margin.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                newInsets.bottom += margin.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            return newInsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    private static Border buttonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    /**
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   827
     * Returns a border instance for a {@code JButton}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   828
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   829
     * @return a border instance for a {@code JButton}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    public static Border getButtonBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        if (buttonBorder == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            buttonBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                                                   new MetalBorders.ButtonBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                                                   new BasicBorders.MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        return buttonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    private static Border textBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    /**
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   844
     * Returns a border instance for a text component.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   845
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   846
     * @return a border instance for a text component
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    public static Border getTextBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        if (textBorder == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            textBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                                                   new MetalBorders.Flush3DBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                                                   new BasicBorders.MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        return textBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    private static Border textFieldBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    /**
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   861
     * Returns a border instance for a {@code JTextField}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   862
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   863
     * @return a border instance for a {@code JTextField}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    public static Border getTextFieldBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        if (textFieldBorder == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            textFieldBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                                                   new MetalBorders.TextFieldBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                                                   new BasicBorders.MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        return textFieldBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   875
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   876
     * The class represents the border of a {@code JTestField}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   877
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   878
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    public static class TextFieldBorder extends Flush3DBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                                int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
          if (!(c instanceof JTextComponent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                // special case for non-text components (bug ID 4144840)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                if (c.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                    MetalUtils.drawFlush3DBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                    MetalUtils.drawDisabledBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            if (c.isEnabled() && ((JTextComponent)c).isEditable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                MetalUtils.drawFlush3DBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                MetalUtils.drawDisabledBorder(g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   903
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   904
     * The class represents the border of a {@code JScrollPane}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   905
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   906
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    public static class ScrollPaneBorder extends AbstractBorder implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        public void paintBorder(Component c, Graphics g, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                          int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
6510
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   911
            if (!(c instanceof JScrollPane)) {
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   912
                return;
75e8a4664c38 6978482: MetalBorders.ToolBarBorder should specify that its getBorderInsets impl accepts only JToolBar inst
malenkov
parents: 5506
diff changeset
   913
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            JScrollPane scroll = (JScrollPane)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            JComponent colHeader = scroll.getColumnHeader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            int colHeaderHeight = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            if (colHeader != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
               colHeaderHeight = colHeader.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            JComponent rowHeader = scroll.getRowHeader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            int rowHeaderWidth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            if (rowHeader != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
               rowHeaderWidth = rowHeader.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            g.translate( x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            g.setColor( MetalLookAndFeel.getControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            g.drawRect( 0, 0, w-2, h-2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            g.setColor( MetalLookAndFeel.getControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            g.drawLine( w-1, 1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            g.drawLine( 1, h-1, w-1, h-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
            g.setColor( MetalLookAndFeel.getControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            g.drawLine( w-2, 2+colHeaderHeight, w-2, 2+colHeaderHeight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            g.drawLine( 1+rowHeaderWidth, h-2, 1+rowHeaderWidth, h-2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            g.translate( -x, -y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            insets.set(1, 1, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    private static Border toggleButtonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    /**
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   952
     * Returns a border instance for a {@code JToggleButton}.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   953
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   954
     * @return a border instance for a {@code JToggleButton}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    public static Border getToggleButtonBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        if (toggleButtonBorder == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                                                   new MetalBorders.ToggleButtonBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                                                   new BasicBorders.MarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        return toggleButtonBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   969
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    public static class ToggleButtonBorder extends ButtonBorder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            AbstractButton button = (AbstractButton)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            ButtonModel model = button.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                if(model.isArmed() || !button.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    super.paintBorder(c, g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                 g.setColor(MetalLookAndFeel.getControlDarkShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                 g.drawRect(0, 0, w - 1, h - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            if (! c.isEnabled() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                MetalUtils.drawDisabledBorder( g, x, y, w-1, h-1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                if ( model.isPressed() && model.isArmed() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                   MetalUtils.drawPressed3DBorder( g, x, y, w, h );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                } else if ( model.isSelected() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                    MetalUtils.drawDark3DBorder( g, x, y, w, h );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                    MetalUtils.drawFlush3DBorder( g, x, y, w, h );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * Border for a Table Header
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
  1002
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
    public static class TableHeaderBorder extends javax.swing.border.AbstractBorder {
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1004
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1005
        /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1006
         * The border insets.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1007
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        protected Insets editorBorderInsets = new Insets( 2, 2, 2, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            g.translate( x, y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            g.setColor( MetalLookAndFeel.getControlDarkShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            g.drawLine( w-1, 0, w-1, h-1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
            g.drawLine( 1, h-1, w-1, h-1 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
            g.setColor( MetalLookAndFeel.getControlHighlight() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            g.drawLine( 0, 0, w-2, 0 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            g.drawLine( 0, 0, 0, h-2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            g.translate( -x, -y );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        public Insets getBorderInsets(Component c, Insets insets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            insets.set(2, 2, 2, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            return insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    /**
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1030
     * Returns a border instance for a Desktop Icon.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1031
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
  1032
     * @return a border instance for a Desktop Icon
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    public static Border getDesktopIconBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        return new BorderUIResource.CompoundBorderUIResource(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                                          new LineBorder(MetalLookAndFeel.getControlDarkShadow(), 1),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                                          new MatteBorder (2,2,1,2, MetalLookAndFeel.getControl()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    static Border getToolBarRolloverBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            return new CompoundBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                new MetalBorders.ButtonBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                new MetalBorders.RolloverMarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        return new CompoundBorder(new MetalBorders.RolloverButtonBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                                  new MetalBorders.RolloverMarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
    static Border getToolBarNonrolloverBorder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            new CompoundBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                new MetalBorders.ButtonBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                new MetalBorders.RolloverMarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        return new CompoundBorder(new MetalBorders.ButtonBorder(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                                  new MetalBorders.RolloverMarginBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
}