jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
author weijun
Thu, 11 Dec 2014 15:19:12 +0800
changeset 28228 be83f404724d
parent 27762 397a31d6d1a6
child 28231 b608ffcaed74
permissions -rw-r--r--
8067207: Replace concat String to append in StringBuilder parameters (client) Reviewed-by: serb Contributed-by: Otavio Santana <otaviojava@java.net>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21278
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 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.basic;
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.accessibility.AccessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.event.InternalFrameEvent;
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 java.beans.PropertyVetoException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.swing.DefaultLookup;
27762
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
    40
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
    41
import static sun.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * The class that manages a basic title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20169
diff changeset
    51
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21278
diff changeset
    58
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public class BasicInternalFrameTitlePane extends JComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
{
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    61
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    62
     * The instance of {@code JMenuBar}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    63
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    protected JMenuBar menuBar;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    65
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    66
     * The iconify button.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    67
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected JButton iconButton;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    69
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    70
     * The maximize button.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    71
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    protected JButton maxButton;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    73
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    74
     * The close button.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    75
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    protected JButton closeButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    78
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    79
     * The instance of {@code JMenu}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    80
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected JMenu windowMenu;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    82
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    83
     * The instance of {@code JInternalFrame}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    84
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    protected JInternalFrame frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    87
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    88
     * The color of a selected title.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    89
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected Color selectedTitleColor;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    91
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    92
     * The color of a selected text.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    93
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    protected Color selectedTextColor;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    95
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    96
     * The color of a not selected title.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    97
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    protected Color notSelectedTitleColor;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
    99
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   100
     * The color of a not selected text.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   101
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    protected Color notSelectedTextColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   104
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   105
     * The maximize icon.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   106
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    protected Icon maxIcon;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   108
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   109
     * The minimize icon.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   110
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    protected Icon minIcon;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   112
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   113
     * The iconify icon.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   114
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected Icon iconIcon;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   116
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   117
     * The close icon.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   118
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    protected Icon closeIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   121
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   122
     * The instance of a {@code PropertyChangeListener}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   123
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    protected PropertyChangeListener propertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   126
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   127
     * The instance of a {@code CloseAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   128
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    protected Action closeAction;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   130
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   131
     * The instance of a {@code MaximizeAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   132
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    protected Action maximizeAction;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   134
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   135
     * The instance of an {@code IconifyAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   136
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    protected Action iconifyAction;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   138
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   139
     * The instance of a {@code RestoreAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   140
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    protected Action restoreAction;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   142
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   143
     * The instance of a {@code MoveAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   144
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    protected Action moveAction;
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   146
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   147
     * The instance of a {@code SizeAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   148
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    protected Action sizeAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   151
    // These constants are not used in JDK code
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   152
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   153
     * The close button text property.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   154
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    protected static final String CLOSE_CMD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        UIManager.getString("InternalFrameTitlePane.closeButtonText");
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   157
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   158
     * The minimize button text property.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   159
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    protected static final String ICONIFY_CMD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        UIManager.getString("InternalFrameTitlePane.minimizeButtonText");
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   162
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   163
     * The restore button text property.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   164
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    protected static final String RESTORE_CMD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        UIManager.getString("InternalFrameTitlePane.restoreButtonText");
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   167
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   168
     * The maximize button text property.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   169
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    protected static final String MAXIMIZE_CMD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        UIManager.getString("InternalFrameTitlePane.maximizeButtonText");
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   172
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   173
     * The move button text property.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   174
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    protected static final String MOVE_CMD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        UIManager.getString("InternalFrameTitlePane.moveButtonText");
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   177
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   178
     * The size button text property.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   179
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    protected static final String SIZE_CMD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        UIManager.getString("InternalFrameTitlePane.sizeButtonText");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    private String closeButtonToolTip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    private String iconButtonToolTip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    private String restoreButtonToolTip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    private String maxButtonToolTip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    private Handler handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   189
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   190
     * Constructs a new instance of {@code BasicInternalFrameTitlePane}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   191
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   192
     * @param f an instance of {@code JInternalFrame}
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   193
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public BasicInternalFrameTitlePane(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        frame = f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        installTitlePane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   199
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   200
     * Installs the title pane.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   201
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    protected void installTitlePane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        createActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        enableActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        createActionMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        setLayout(createLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        assembleSystemMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        createButtons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        addSubComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
27762
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
   216
        updateProperties();
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
   217
    }
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
   218
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
   219
    private void updateProperties() {
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
   220
        final Object aaTextInfo = frame.getClientProperty(AA_TEXT_PROPERTY_KEY);
397a31d6d1a6 7169583: JInternalFrame title not antialiased in Nimbus LaF
serb
parents: 25859
diff changeset
   221
        putClientProperty(AA_TEXT_PROPERTY_KEY, aaTextInfo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   224
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   225
     * Adds subcomponents.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   226
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    protected void addSubComponents() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        add(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        add(iconButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        add(maxButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        add(closeButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   234
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   235
     * Creates actions.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   236
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    protected void createActions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        maximizeAction = new MaximizeAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        iconifyAction = new IconifyAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        closeAction = new CloseAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        restoreAction = new RestoreAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        moveAction = new MoveAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        sizeAction = new SizeAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    ActionMap createActionMap() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        ActionMap map = new ActionMapUIResource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        map.put("showSystemMenu", new ShowSystemMenuAction(true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        map.put("hideSystemMenu", new ShowSystemMenuAction(false));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   253
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   254
     * Registers listeners.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   255
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        if( propertyChangeListener == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            propertyChangeListener = createPropertyChangeListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        frame.addPropertyChangeListener(propertyChangeListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   263
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   264
     * Unregisters listeners.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   265
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        frame.removePropertyChangeListener(propertyChangeListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        handler = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   271
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   272
     * Installs default properties.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   273
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        minIcon = UIManager.getIcon("InternalFrame.minimizeIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        selectedTextColor = UIManager.getColor("InternalFrame.activeTitleForeground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        notSelectedTextColor = UIManager.getColor("InternalFrame.inactiveTitleForeground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        setFont(UIManager.getFont("InternalFrame.titleFont"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        closeButtonToolTip =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                UIManager.getString("InternalFrame.closeButtonToolTip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        iconButtonToolTip =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                UIManager.getString("InternalFrame.iconButtonToolTip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        restoreButtonToolTip =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                UIManager.getString("InternalFrame.restoreButtonToolTip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        maxButtonToolTip =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                UIManager.getString("InternalFrame.maxButtonToolTip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   295
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   296
     * Uninstalls default properties.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   297
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   301
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   302
     * Creates buttons.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   303
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    protected void createButtons() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        iconButton = new NoFocusButton(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                     "InternalFrameTitlePane.iconifyButtonAccessibleName",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                     "InternalFrameTitlePane.iconifyButtonOpacity");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        iconButton.addActionListener(iconifyAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if (iconButtonToolTip != null && iconButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            iconButton.setToolTipText(iconButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        maxButton = new NoFocusButton(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                        "InternalFrameTitlePane.maximizeButtonAccessibleName",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                        "InternalFrameTitlePane.maximizeButtonOpacity");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        maxButton.addActionListener(maximizeAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        closeButton = new NoFocusButton(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                      "InternalFrameTitlePane.closeButtonAccessibleName",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                      "InternalFrameTitlePane.closeButtonOpacity");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        closeButton.addActionListener(closeAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        if (closeButtonToolTip != null && closeButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            closeButton.setToolTipText(closeButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        setButtonIcons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   329
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   330
     * Sets the button icons.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   331
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    protected void setButtonIcons() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if(frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            if (minIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                iconButton.setIcon(minIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            if (restoreButtonToolTip != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                    restoreButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                iconButton.setToolTipText(restoreButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            if (maxIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                maxButton.setIcon(maxIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            if (maxButtonToolTip != null && maxButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                maxButton.setToolTipText(maxButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        } else if (frame.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            if (iconIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                iconButton.setIcon(iconIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            if (iconButtonToolTip != null && iconButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                iconButton.setToolTipText(iconButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            if (minIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                maxButton.setIcon(minIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            if (restoreButtonToolTip != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    restoreButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                maxButton.setToolTipText(restoreButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            if (iconIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                iconButton.setIcon(iconIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            if (iconButtonToolTip != null && iconButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                iconButton.setToolTipText(iconButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            if (maxIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                maxButton.setIcon(maxIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            if (maxButtonToolTip != null && maxButtonToolTip.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                maxButton.setToolTipText(maxButtonToolTip);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        if (closeIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            closeButton.setIcon(closeIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   380
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   381
     * Assembles system menu.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   382
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    protected void assembleSystemMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        menuBar = createSystemMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        windowMenu = createSystemMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        menuBar.add(windowMenu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        addSystemMenuItems(windowMenu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        enableActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   391
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   392
     * Adds system menu items to {@code systemMenu}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   393
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   394
     * @param systemMenu an instance of {@code JMenu}
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   395
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    protected void addSystemMenuItems(JMenu systemMenu) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   397
        JMenuItem mi = systemMenu.add(restoreAction);
21259
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   398
        mi.setMnemonic(getButtonMnemonic("restore"));
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   399
        mi = systemMenu.add(moveAction);
21259
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   400
        mi.setMnemonic(getButtonMnemonic("move"));
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   401
        mi = systemMenu.add(sizeAction);
21259
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   402
        mi.setMnemonic(getButtonMnemonic("size"));
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   403
        mi = systemMenu.add(iconifyAction);
21259
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   404
        mi.setMnemonic(getButtonMnemonic("minimize"));
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   405
        mi = systemMenu.add(maximizeAction);
21259
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   406
        mi.setMnemonic(getButtonMnemonic("maximize"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        systemMenu.add(new JSeparator());
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   408
        mi = systemMenu.add(closeAction);
21259
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   409
        mi.setMnemonic(getButtonMnemonic("close"));
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   410
    }
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   411
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   412
    private static int getButtonMnemonic(String button) {
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   413
        try {
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   414
            return Integer.parseInt(UIManager.getString(
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   415
                    "InternalFrameTitlePane." + button + "Button.mnemonic"));
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   416
        } catch (NumberFormatException e) {
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   417
            return -1;
4780cf380d96 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
alexsch
parents: 20458
diff changeset
   418
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   421
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   422
     * Returns a new instance of {@code JMenu}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   423
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   424
     * @return a new instance of {@code JMenu}
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   425
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    protected JMenu createSystemMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return new JMenu("    ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   430
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   431
     * Returns a new instance of {@code JMenuBar}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   432
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   433
     * @return a new instance of {@code JMenuBar}
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   434
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    protected JMenuBar createSystemMenuBar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        menuBar = new SystemMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        menuBar.setBorderPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        return menuBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   441
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   442
     * Shows system menu.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   443
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    protected void showSystemMenu(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        //      windowMenu.setPopupMenuVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
      //      windowMenu.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
      windowMenu.doClick();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public void paintComponent(Graphics g)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        paintTitleBackground(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        if(frame.getTitle() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            boolean isSelected = frame.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            Font f = g.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            g.setFont(getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            if(isSelected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                g.setColor(selectedTextColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                g.setColor(notSelectedTextColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            // Center text vertically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    fm.getDescent()) / 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            int titleX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            Rectangle r = new Rectangle(0, 0, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            if (frame.isIconifiable())  r = iconButton.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            else if (frame.isMaximizable())  r = maxButton.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            else if (frame.isClosable())  r = closeButton.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            int titleW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            String title = frame.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            if( BasicGraphicsUtils.isLeftToRight(frame) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
              if (r.x == 0)  r.x = frame.getWidth()-frame.getInsets().right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
              titleX = menuBar.getX() + menuBar.getWidth() + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
              titleW = r.x - titleX - 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
              title = getTitle(frame.getTitle(), fm, titleW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                titleX = menuBar.getX() - 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                         - SwingUtilities2.stringWidth(frame,fm,title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            SwingUtilities2.drawString(frame, g, title, titleX, baseline);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            g.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    * Invoked from paintComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    * Paints the background of the titlepane.  All text and icons will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    * then be rendered on top of this background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    * @param g the graphics to use to render the background
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    protected void paintTitleBackground(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        boolean isSelected = frame.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        if(isSelected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            g.setColor(selectedTitleColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            g.setColor(notSelectedTitleColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        g.fillRect(0, 0, getWidth(), getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   507
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   508
     * Returns the title.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   509
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   510
     * @param text a text
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   511
     * @param fm an instance of {@code FontMetrics}
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   512
     * @param availTextWidth an available text width
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   513
     * @return the title.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   514
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    protected String getTitle(String text, FontMetrics fm, int availTextWidth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        return SwingUtilities2.clipStringIfNecessary(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                           frame, fm, text, availTextWidth);
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   518
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * Post a WINDOW_CLOSING-like event to the frame, so that it can
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   522
     * be treated like a regular {@code Frame}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   523
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   524
     * @param frame an instance of {@code JInternalFrame}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    protected void postClosingEvent(JInternalFrame frame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        InternalFrameEvent e = new InternalFrameEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        // Try posting event, unless there's a SecurityManager.
25096
6aff20f916b2 8043456: KSS: javax.swing.plaf.basic.BasicInternalFrameTitlePane#postClosingEvent
malenkov
parents: 22574
diff changeset
   530
        try {
6aff20f916b2 8043456: KSS: javax.swing.plaf.basic.BasicInternalFrameTitlePane#postClosingEvent
malenkov
parents: 22574
diff changeset
   531
            Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
6aff20f916b2 8043456: KSS: javax.swing.plaf.basic.BasicInternalFrameTitlePane#postClosingEvent
malenkov
parents: 22574
diff changeset
   532
        } catch (SecurityException se) {
6aff20f916b2 8043456: KSS: javax.swing.plaf.basic.BasicInternalFrameTitlePane#postClosingEvent
malenkov
parents: 22574
diff changeset
   533
            frame.dispatchEvent(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   537
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   538
     * Enables actions.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   539
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    protected void enableActions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        restoreAction.setEnabled(frame.isMaximum() || frame.isIcon());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        maximizeAction.setEnabled(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            (frame.isMaximizable() && !frame.isMaximum() && !frame.isIcon()) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            (frame.isMaximizable() && frame.isIcon()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        iconifyAction.setEnabled(frame.isIconifiable() && !frame.isIcon());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        closeAction.setEnabled(frame.isClosable());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        sizeAction.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        moveAction.setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    private Handler getHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            handler = new Handler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   558
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   559
     * Returns an instance of {@code PropertyChangeListener}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   560
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   561
     * @return an instance of {@code PropertyChangeListener}
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   562
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    protected PropertyChangeListener createPropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   567
    /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   568
     * Returns a layout manager.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   569
     *
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   570
     * @return a layout manager
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   571
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    protected LayoutManager createLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    private class Handler implements LayoutManager, PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        // PropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        public void propertyChange(PropertyChangeEvent evt) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   582
            String prop = evt.getPropertyName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            if (prop == JInternalFrame.IS_SELECTED_PROPERTY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            if (prop == JInternalFrame.IS_ICON_PROPERTY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                    prop == JInternalFrame.IS_MAXIMUM_PROPERTY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                setButtonIcons();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                enableActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            if ("closable" == prop) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   597
                if (evt.getNewValue() == Boolean.TRUE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                    add(closeButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                    remove(closeButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            } else if ("maximizable" == prop) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   603
                if (evt.getNewValue() == Boolean.TRUE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                    add(maxButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                    remove(maxButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            } else if ("iconable" == prop) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   609
                if (evt.getNewValue() == Boolean.TRUE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                    add(iconButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    remove(iconButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            enableActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        // LayoutManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        public void addLayoutComponent(String name, Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        public void removeLayoutComponent(Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        public Dimension preferredLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            return minimumLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            // Calculate width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            int width = 22;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            if (frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                width += 19;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            if (frame.isMaximizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                width += 19;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            if (frame.isIconifiable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                width += 19;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            FontMetrics fm = frame.getFontMetrics(getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            String frameTitle = frame.getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            int title_w = frameTitle != null ? SwingUtilities2.stringWidth(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                               frame, fm, frameTitle) : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            int title_length = frameTitle != null ? frameTitle.length() : 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            // Leave room for three characters in the title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            if (title_length > 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                int subtitle_w = SwingUtilities2.stringWidth(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                    frame, fm, frameTitle.substring(0, 3) + "...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                width += (title_w < subtitle_w) ? title_w : subtitle_w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                width += title_w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            // Calculate height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            Icon icon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            int fontHeight = fm.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            fontHeight += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            int iconHeight = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            if (icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                // SystemMenuBar forces the icon to be 16x16 or less.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                iconHeight = Math.min(icon.getIconHeight(), 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            iconHeight += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            int height = Math.max( fontHeight, iconHeight );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            Dimension dim = new Dimension(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            // Take into account the border insets if any.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            if (getBorder() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                Insets insets = getBorder().getBorderInsets(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                dim.height += insets.top + insets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                dim.width += insets.left + insets.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            return dim;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        public void layoutContainer(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            boolean leftToRight = BasicGraphicsUtils.isLeftToRight(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            int w = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            int h = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            int x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            int buttonHeight = closeButton.getIcon().getIconHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            Icon icon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            int iconHeight = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            if (icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                iconHeight = icon.getIconHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            x = (leftToRight) ? 2 : w - 16 - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            menuBar.setBounds(x, (h - iconHeight) / 2, 16, 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            x = (leftToRight) ? w - 16 - 2 : 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            if (frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                closeButton.setBounds(x, (h - buttonHeight) / 2, 16, 14);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                x += (leftToRight) ? -(16 + 2) : 16 + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            if (frame.isMaximizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                maxButton.setBounds(x, (h - buttonHeight) / 2, 16, 14);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                x += (leftToRight) ? -(16 + 2) : 16 + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            if (frame.isIconifiable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                iconButton.setBounds(x, (h - buttonHeight) / 2, 16, 14);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   721
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    public class PropertyChangeHandler implements PropertyChangeListener {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21259
diff changeset
   724
        // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            getHandler().propertyChange(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   735
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    public class TitlePaneLayout implements LayoutManager {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21259
diff changeset
   738
        // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        public void addLayoutComponent(String name, Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            getHandler().addLayoutComponent(name, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        public void removeLayoutComponent(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
            getHandler().removeLayoutComponent(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        public Dimension preferredLayoutSize(Container c)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            return getHandler().preferredLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            return getHandler().minimumLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        public void layoutContainer(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            getHandler().layoutContainer(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   765
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    public class CloseAction extends AbstractAction {
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   768
        /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   769
         * Constructs a new instance of a {@code CloseAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   770
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        public CloseAction() {
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   772
            super(UIManager.getString(
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   773
                    "InternalFrameTitlePane.closeButtonText"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            if(frame.isClosable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                frame.doDefaultCloseAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    } // end CloseAction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   785
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    public class MaximizeAction extends AbstractAction {
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   788
        /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   789
         * Constructs a new instance of a {@code MaximizeAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   790
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        public MaximizeAction() {
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   792
            super(UIManager.getString(
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   793
                    "InternalFrameTitlePane.maximizeButtonText"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            if (frame.isMaximizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                if (frame.isMaximum() && frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                        frame.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                    } catch (PropertyVetoException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                } else if (!frame.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                        frame.setMaximum(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                    } catch (PropertyVetoException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                        frame.setMaximum(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                    } catch (PropertyVetoException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   817
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    public class IconifyAction extends AbstractAction {
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   820
        /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   821
         * Constructs a new instance of an {@code IconifyAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   822
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        public IconifyAction() {
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   824
            super(UIManager.getString(
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   825
                    "InternalFrameTitlePane.minimizeButtonText"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            if(frame.isIconifiable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
              if(!frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                try { frame.setIcon(true); } catch (PropertyVetoException e1) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
              } else{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                try { frame.setIcon(false); } catch (PropertyVetoException e1) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    } // end IconifyAction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   841
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    public class RestoreAction extends AbstractAction {
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   844
        /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   845
         * Constructs a new instance of a {@code RestoreAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   846
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        public RestoreAction() {
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   848
            super(UIManager.getString(
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   849
                    "InternalFrameTitlePane.restoreButtonText"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            if (frame.isMaximizable() && frame.isMaximum() && frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                    frame.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                } catch (PropertyVetoException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            } else if (frame.isMaximizable() && frame.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                    frame.setMaximum(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                } catch (PropertyVetoException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            } else if (frame.isIconifiable() && frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    frame.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                } catch (PropertyVetoException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   871
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    public class MoveAction extends AbstractAction {
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   874
        /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   875
         * Constructs a new instance of a {@code MoveAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   876
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        public MoveAction() {
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   878
            super(UIManager.getString(
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   879
                    "InternalFrameTitlePane.moveButtonText"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            // This action is currently undefined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    } // end MoveAction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * Handles showing and hiding the system menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    private class ShowSystemMenuAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        private boolean show;   // whether to show the menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        public ShowSystemMenuAction(boolean show) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            this.show = show;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            if (show) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                windowMenu.doClick();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                windowMenu.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   908
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    public class SizeAction extends AbstractAction {
25772
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   911
        /**
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   912
         * Constructs a new instance of a {@code SizeAction}.
73e0efa29d55 8049870: Fix doclint warnings from javax.swing.plaf.basic package, 4 of 7
aeremeev
parents: 25096
diff changeset
   913
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        public SizeAction() {
1285
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   915
            super(UIManager.getString(
d2d433263986 6725409: Unable to localize JInternalFrame system menu during run-time
mlapshin
parents: 2
diff changeset
   916
                    "InternalFrameTitlePane.sizeButtonText"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            // This action is currently undefined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    } // end SizeAction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * This class should be treated as a &quot;protected&quot; inner class.
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
   927
     * Instantiate it only within subclasses of <code>Foo</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    public class SystemMenuBar extends JMenuBar {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        public boolean isFocusTraversable() { return false; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        public void requestFocus() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        public void paint(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            Icon icon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            if (icon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
              icon = (Icon)DefaultLookup.get(frame, frame.getUI(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                      "InternalFrame.icon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            if (icon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                // Resize to 16x16 if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                if (icon instanceof ImageIcon && (icon.getIconWidth() > 16 || icon.getIconHeight() > 16)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                    Image img = ((ImageIcon)icon).getImage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                    ((ImageIcon)icon).setImage(img.getScaledInstance(16, 16, Image.SCALE_SMOOTH));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                icon.paintIcon(this, g, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        public boolean isOpaque() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    } // end SystemMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    private class NoFocusButton extends JButton {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        private String uiKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        public NoFocusButton(String uiKey, String opacityKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            setFocusPainted(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            setMargin(new Insets(0,0,0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            this.uiKey = uiKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            Object opacity = UIManager.get(opacityKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            if (opacity instanceof Boolean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                setOpaque(((Boolean)opacity).booleanValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        public boolean isFocusTraversable() { return false; }
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   967
        public void requestFocus() {}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            AccessibleContext ac = super.getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            if (uiKey != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                ac.setAccessibleName(UIManager.getString(uiKey));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                uiKey = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            return ac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        }
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1285
diff changeset
   976
    }  // end NoFocusButton
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
}   // End Title Pane Class