jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.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: 5506
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: 1639
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: 1639
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: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
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 sun.swing.SwingUtilities2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.event.InternalFrameEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Class that manages a JLF title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author Brian Beck
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 5506
diff changeset
    46
@SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class MetalInternalFrameTitlePane  extends BasicInternalFrameTitlePane {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    49
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    50
     * The value {@code isPalette}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    51
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    protected boolean isPalette = false;
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    53
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    54
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    55
     * The palette close icon.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    56
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected Icon paletteCloseIcon;
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    58
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 height of the palette title.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
    61
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    protected int paletteTitleHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Key used to lookup Color from UIManager. If this is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * <code>getWindowTitleBackground</code> is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private String selectedBackgroundKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Key used to lookup Color from UIManager. If this is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * <code>getWindowTitleForeground</code> is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private String selectedForegroundKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Key used to lookup shadow color from UIManager. If this is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <code>getPrimaryControlDarkShadow</code> is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private String selectedShadowKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Boolean indicating the state of the <code>JInternalFrame</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * closable property at <code>updateUI</code> time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private boolean wasClosable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    int buttonsWidth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    MetalBumps activeBumps
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        = new MetalBumps( 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                          MetalLookAndFeel.getPrimaryControlHighlight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                          MetalLookAndFeel.getPrimaryControlDarkShadow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
          (UIManager.get("InternalFrame.activeTitleGradient") != null) ? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                          MetalLookAndFeel.getPrimaryControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    MetalBumps inactiveBumps
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        = new MetalBumps( 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                          MetalLookAndFeel.getControlHighlight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                          MetalLookAndFeel.getControlDarkShadow(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        (UIManager.get("InternalFrame.inactiveTitleGradient") != null) ? null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                          MetalLookAndFeel.getControl() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    MetalBumps paletteBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private Color activeBumpsHighlight = MetalLookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                             getPrimaryControlHighlight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private Color activeBumpsShadow = MetalLookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                             getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   108
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   109
     * Constructs a new instance of {@code MetalInternalFrameTitlePane}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   110
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   111
     * @param f an instance of {@code JInternalFrame}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   112
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public MetalInternalFrameTitlePane(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        super( f );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        // This is done here instead of in installDefaults as I was worried
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        // that the BasicInternalFrameUI might not be fully initialized, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        // that if this resets the closable state the BasicInternalFrameUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        // Listeners that get notified might be in an odd/uninitialized state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        updateOptionPaneState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        super.installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        setFont( UIManager.getFont("InternalFrame.titleFont") );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        paletteTitleHeight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            = UIManager.getInt("InternalFrame.paletteTitleHeight");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        wasClosable = frame.isClosable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        selectedForegroundKey = selectedBackgroundKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        super.uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (wasClosable != frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            frame.setClosable(wasClosable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    protected void createButtons() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        super.createButtons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        Boolean paintActive = frame.isSelected() ? Boolean.TRUE:Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        iconButton.putClientProperty("paintActive", paintActive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        iconButton.setBorder(handyEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        maxButton.putClientProperty("paintActive", paintActive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        maxButton.setBorder(handyEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        closeButton.putClientProperty("paintActive", paintActive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        closeButton.setBorder(handyEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        // The palette close icon isn't opaque while the regular close icon is.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        // This makes sure palette close buttons have the right background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        closeButton.setBackground(MetalLookAndFeel.getPrimaryControlShadow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        if (MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            iconButton.setContentAreaFilled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            maxButton.setContentAreaFilled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            closeButton.setContentAreaFilled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Override the parent's method to do nothing. Metal frames do not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * have system menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    protected void assembleSystemMenu() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Override the parent's method to do nothing. Metal frames do not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * have system menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    protected void addSystemMenuItems(JMenu systemMenu) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Override the parent's method to do nothing. Metal frames do not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * have system menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    protected void showSystemMenu() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Override the parent's method avoid creating a menu bar. Metal frames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * do not have system menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    protected void addSubComponents() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        add(iconButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        add(maxButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        add(closeButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    protected PropertyChangeListener createPropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return new MetalPropertyChangeHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    protected LayoutManager createLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return new MetalTitlePaneLayout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    class MetalPropertyChangeHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        extends BasicInternalFrameTitlePane.PropertyChangeHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        public void propertyChange(PropertyChangeEvent evt) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   210
            String prop = evt.getPropertyName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                Boolean b = (Boolean)evt.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                iconButton.putClientProperty("paintActive", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                closeButton.putClientProperty("paintActive", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                maxButton.putClientProperty("paintActive", b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            else if ("JInternalFrame.messageType".equals(prop)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                updateOptionPaneState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                frame.repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            super.propertyChange(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    class MetalTitlePaneLayout extends TitlePaneLayout {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        public void addLayoutComponent(String name, Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        public void removeLayoutComponent(Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        public Dimension preferredLayoutSize(Container c)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            return minimumLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            // Compute width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            int width = 30;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            if (frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                width += 21;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            if (frame.isMaximizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                width += 16 + (frame.isClosable() ? 10 : 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            if (frame.isIconifiable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                width += 16 + (frame.isMaximizable() ? 2 :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    (frame.isClosable() ? 10 : 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            FontMetrics fm = frame.getFontMetrics(getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            String frameTitle = frame.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            int title_w = frameTitle != null ? SwingUtilities2.stringWidth(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                               frame, fm, frameTitle) : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            int title_length = frameTitle != null ? frameTitle.length() : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            if (title_length > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                int subtitle_w = SwingUtilities2.stringWidth(frame, fm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                     frame.getTitle().substring(0, 2) + "...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                width += (title_w < subtitle_w) ? title_w : subtitle_w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                width += title_w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            // Compute height.
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   261
            int height;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            if (isPalette) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                height = paletteTitleHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                int fontHeight = fm.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                fontHeight += 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                Icon icon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                int iconHeight = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                if (icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                    // SystemMenuBar forces the icon to be 16x16 or less.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                    iconHeight = Math.min(icon.getIconHeight(), 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                iconHeight += 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                height = Math.max(fontHeight, iconHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            return new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        public void layoutContainer(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            boolean leftToRight = MetalUtils.isLeftToRight(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            int w = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            int x = leftToRight ? w : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            int y = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            int spacing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            // assumes all buttons have the same dimensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            // these dimensions include the borders
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            int buttonHeight = closeButton.getIcon().getIconHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            int buttonWidth = closeButton.getIcon().getIconWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            if(frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                if (isPalette) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    spacing = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    x += leftToRight ? -spacing -(buttonWidth+2) : spacing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    closeButton.setBounds(x, y, buttonWidth+2, getHeight()-4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                    if( !leftToRight ) x += (buttonWidth+2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                    spacing = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                    x += leftToRight ? -spacing -buttonWidth : spacing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                    closeButton.setBounds(x, y, buttonWidth, buttonHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                    if( !leftToRight ) x += buttonWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            if(frame.isMaximizable() && !isPalette ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                spacing = frame.isClosable() ? 10 : 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                x += leftToRight ? -spacing -buttonWidth : spacing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                maxButton.setBounds(x, y, buttonWidth, buttonHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                if( !leftToRight ) x += buttonWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            if(frame.isIconifiable() && !isPalette ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                spacing = frame.isMaximizable() ? 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                          : (frame.isClosable() ? 10 : 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                x += leftToRight ? -spacing -buttonWidth : spacing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                iconButton.setBounds(x, y, buttonWidth, buttonHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                if( !leftToRight ) x += buttonWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            buttonsWidth = leftToRight ? w - x : x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   326
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   327
     * Paints palette.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   328
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   329
     * @param g a instance of {@code Graphics}
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   330
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public void paintPalette(Graphics g)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        boolean leftToRight = MetalUtils.isLeftToRight(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        int width = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        int height = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        if (paletteBumps == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            paletteBumps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                = new MetalBumps(0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                 MetalLookAndFeel.getPrimaryControlHighlight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                 MetalLookAndFeel.getPrimaryControlInfo(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                 MetalLookAndFeel.getPrimaryControlShadow() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        Color background = MetalLookAndFeel.getPrimaryControlShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        g.fillRect(0, 0, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        g.setColor( darkShadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        g.drawLine ( 0, height - 1, width, height -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        int xOffset = leftToRight ? 4 : buttonsWidth + 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        int bumpLength = width - buttonsWidth -2*4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        int bumpHeight = getHeight()  - 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        paletteBumps.setBumpArea( bumpLength, bumpHeight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        paletteBumps.paintIcon( this, g, xOffset, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public void paintComponent(Graphics g)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        if(isPalette) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            paintPalette(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        boolean leftToRight = MetalUtils.isLeftToRight(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        boolean isSelected = frame.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        int width = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        int height = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        Color background = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        Color foreground = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        Color shadow = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        MetalBumps bumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        String gradientKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            if (!MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                closeButton.setContentAreaFilled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                maxButton.setContentAreaFilled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                iconButton.setContentAreaFilled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            if (selectedBackgroundKey != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                background = UIManager.getColor(selectedBackgroundKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            if (background == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                background = MetalLookAndFeel.getWindowTitleBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            if (selectedForegroundKey != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                foreground = UIManager.getColor(selectedForegroundKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            if (selectedShadowKey != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                shadow = UIManager.getColor(selectedShadowKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            if (shadow == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                shadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            if (foreground == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                foreground = MetalLookAndFeel.getWindowTitleForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            activeBumps.setBumpColors(activeBumpsHighlight, activeBumpsShadow,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                        UIManager.get("InternalFrame.activeTitleGradient") !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                                      null ? null : background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            bumps = activeBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            gradientKey = "InternalFrame.activeTitleGradient";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            if (!MetalLookAndFeel.usingOcean()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                closeButton.setContentAreaFilled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                maxButton.setContentAreaFilled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                iconButton.setContentAreaFilled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            background = MetalLookAndFeel.getWindowTitleInactiveBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            foreground = MetalLookAndFeel.getWindowTitleInactiveForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            shadow = MetalLookAndFeel.getControlDarkShadow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            bumps = inactiveBumps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            gradientKey = "InternalFrame.inactiveTitleGradient";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        if (!MetalUtils.drawGradient(this, g, gradientKey, 0, 0, width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                     height, true)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            g.setColor(background);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            g.fillRect(0, 0, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        g.setColor( shadow );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        g.drawLine ( 0, height - 1, width, height -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        g.drawLine ( 0, 0, 0 ,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        g.drawLine ( width - 1, 0 , width -1, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 2
diff changeset
   434
        int titleLength;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        int xOffset = leftToRight ? 5 : width - 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        String frameTitle = frame.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        Icon icon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        if ( icon != null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if( !leftToRight )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                xOffset -= icon.getIconWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            int iconY = ((height / 2) - (icon.getIconHeight() /2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            icon.paintIcon(frame, g, xOffset, iconY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            xOffset += leftToRight ? icon.getIconWidth() + 5 : -5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        if(frameTitle != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            Font f = getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            g.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            int fHeight = fm.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            g.setColor(foreground);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            int yOffset = ( (height - fm.getHeight() ) / 2 ) + fm.getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            Rectangle rect = new Rectangle(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            if (frame.isIconifiable()) { rect = iconButton.getBounds(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            else if (frame.isMaximizable()) { rect = maxButton.getBounds(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            else if (frame.isClosable()) { rect = closeButton.getBounds(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            int titleW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            if( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
              if (rect.x == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                rect.x = frame.getWidth()-frame.getInsets().right-2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
              titleW = rect.x - xOffset - 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
              frameTitle = getTitle(frameTitle, fm, titleW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
              titleW = xOffset - rect.x - rect.width - 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
              frameTitle = getTitle(frameTitle, fm, titleW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
              xOffset -= SwingUtilities2.stringWidth(frame, fm, frameTitle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            titleLength = SwingUtilities2.stringWidth(frame, fm, frameTitle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            SwingUtilities2.drawString(frame, g, frameTitle, xOffset, yOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            xOffset += leftToRight ? titleLength + 5  : -5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        int bumpXOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        int bumpLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        if( leftToRight ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            bumpLength = width - buttonsWidth - xOffset - 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            bumpXOffset = xOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            bumpLength = xOffset - buttonsWidth - 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            bumpXOffset = buttonsWidth + 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        int bumpYOffset = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        int bumpHeight = getHeight() - (2 * bumpYOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        bumps.setBumpArea( bumpLength, bumpHeight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
25178
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   495
    /**
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   496
     * If {@code b} is {@code true}, sets palette icons.
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   497
     *
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   498
     * @param b if {@code true}, sets palette icons
dbab904451e9 8046434: Fix doclint warnings from javax.swing.plaf.metal package
yan
parents: 23697
diff changeset
   499
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    public void setPalette(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        isPalette = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        if (isPalette) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            closeButton.setIcon(paletteCloseIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
         if( frame.isMaximizable() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                remove(maxButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            if( frame.isIconifiable() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                remove(iconButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            closeButton.setIcon(closeIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            if( frame.isMaximizable() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                add(maxButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            if( frame.isIconifiable() )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                add(iconButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * Updates any state dependant upon the JInternalFrame being shown in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * a <code>JOptionPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    private void updateOptionPaneState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        int type = -2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        boolean closable = wasClosable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        Object obj = frame.getClientProperty("JInternalFrame.messageType");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        if (obj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            // Don't change the closable state unless in an JOptionPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        if (obj instanceof Integer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            type = ((Integer) obj).intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        case JOptionPane.ERROR_MESSAGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            selectedBackgroundKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                              "OptionPane.errorDialog.titlePane.background";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            selectedForegroundKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                              "OptionPane.errorDialog.titlePane.foreground";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            selectedShadowKey = "OptionPane.errorDialog.titlePane.shadow";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            closable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        case JOptionPane.QUESTION_MESSAGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            selectedBackgroundKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                            "OptionPane.questionDialog.titlePane.background";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            selectedForegroundKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    "OptionPane.questionDialog.titlePane.foreground";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            selectedShadowKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                          "OptionPane.questionDialog.titlePane.shadow";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            closable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        case JOptionPane.WARNING_MESSAGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            selectedBackgroundKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                              "OptionPane.warningDialog.titlePane.background";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            selectedForegroundKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                              "OptionPane.warningDialog.titlePane.foreground";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            selectedShadowKey = "OptionPane.warningDialog.titlePane.shadow";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            closable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        case JOptionPane.INFORMATION_MESSAGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        case JOptionPane.PLAIN_MESSAGE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            selectedBackgroundKey = selectedForegroundKey = selectedShadowKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                                    null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            closable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            selectedBackgroundKey = selectedForegroundKey = selectedShadowKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                                    null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        if (closable != frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            frame.setClosable(closable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
}