jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDesktopPaneUI.java
author weijun
Thu, 11 Dec 2014 15:19:12 +0800
changeset 28228 be83f404724d
parent 25859 3317bb8137f4
child 28991 c9b7acf9062d
permissions -rw-r--r--
8067207: Replace concat String to append in StringBuilder parameters (client) Reviewed-by: serb Contributed-by: Otavio Santana <otaviojava@java.net>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.basic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Insets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.KeyboardFocusManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.swing.DefaultLookup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.swing.UIAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
    45
 * Basic L&amp;F for a desktop.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author Steve Wilson
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class BasicDesktopPaneUI extends DesktopPaneUI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    // Old actions forward to an instance of this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static final Actions SHARED_ACTION = new Actions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static Dimension minSize = new Dimension(0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private static Dimension maxSize = new Dimension(Integer.MAX_VALUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private Handler handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private PropertyChangeListener pcl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    58
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    59
     * The instance of {@code JDesktopPane}.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    60
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected JDesktopPane desktop;
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    62
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    63
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    64
     * The instance of {@code DesktopManager}.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
    65
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected DesktopManager desktopManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    protected KeyStroke minimizeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    protected KeyStroke maximizeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    protected KeyStroke closeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    protected KeyStroke navigateKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    protected KeyStroke navigateKey2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   119
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   120
     * Constructs a new instance of {@code BasicDesktopPaneUI}.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   121
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   122
     * @param c a component
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   123
     * @return a new instance of {@code BasicDesktopPaneUI}
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   124
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public static ComponentUI createUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return new BasicDesktopPaneUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   129
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   130
     * Constructs a new instance of {@code BasicDesktopPaneUI}.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   131
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public BasicDesktopPaneUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public void installUI(JComponent c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        desktop = (JDesktopPane)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        installDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public void uninstallUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        uninstallDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        desktop = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        handler = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   152
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   153
     * Installs default properties.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   154
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (desktop.getBackground() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            desktop.getBackground() instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            desktop.setBackground(UIManager.getColor("Desktop.background"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        LookAndFeel.installProperty(desktop, "opaque", Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   163
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   164
     * Uninstalls default properties.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   165
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    protected void uninstallDefaults() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Installs the <code>PropertyChangeListener</code> returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * <code>createPropertyChangeListener</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @see #createPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        pcl = createPropertyChangeListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        desktop.addPropertyChangeListener(pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Uninstalls the <code>PropertyChangeListener</code> returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <code>createPropertyChangeListener</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @see #createPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        desktop.removePropertyChangeListener(pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        pcl = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   194
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   195
     * Installs desktop manager.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   196
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    protected void installDesktopManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        desktopManager = desktop.getDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if(desktopManager == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            desktopManager = new BasicDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            desktop.setDesktopManager(desktopManager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   205
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   206
     * Uninstalls desktop manager.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   207
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    protected void uninstallDesktopManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        if(desktop.getDesktopManager() instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            desktop.setDesktopManager(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        desktopManager = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   215
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   216
     * Installs keyboard actions.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   217
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    protected void installKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (inputMap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            SwingUtilities.replaceUIInputMap(desktop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                        JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (inputMap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            SwingUtilities.replaceUIInputMap(desktop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                        inputMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        LazyActionMap.installLazyActionMap(desktop, BasicDesktopPaneUI.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                "DesktopPane.actionMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        registerKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   236
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   237
     * Registers keyboard actions.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   238
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    protected void registerKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   242
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   243
     * Unregisters keyboard actions.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   244
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    protected void unregisterKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    InputMap getInputMap(int condition) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            return createInputMap(condition);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        else if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            return (InputMap)DefaultLookup.get(desktop, this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                    "Desktop.ancestorInputMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    InputMap createInputMap(int condition) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            Object[] bindings = (Object[])DefaultLookup.get(desktop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                    this, "Desktop.windowBindings");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            if (bindings != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                return LookAndFeel.makeComponentInputMap(desktop, bindings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    static void loadActionMap(LazyActionMap map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        map.put(new Actions(Actions.RESTORE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        map.put(new Actions(Actions.CLOSE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        map.put(new Actions(Actions.MOVE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        map.put(new Actions(Actions.RESIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        map.put(new Actions(Actions.LEFT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        map.put(new Actions(Actions.SHRINK_LEFT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        map.put(new Actions(Actions.RIGHT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        map.put(new Actions(Actions.SHRINK_RIGHT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        map.put(new Actions(Actions.UP));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        map.put(new Actions(Actions.SHRINK_UP));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        map.put(new Actions(Actions.DOWN));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        map.put(new Actions(Actions.SHRINK_DOWN));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        map.put(new Actions(Actions.ESCAPE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        map.put(new Actions(Actions.MINIMIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        map.put(new Actions(Actions.MAXIMIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        map.put(new Actions(Actions.NEXT_FRAME));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        map.put(new Actions(Actions.PREVIOUS_FRAME));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        map.put(new Actions(Actions.NAVIGATE_NEXT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        map.put(new Actions(Actions.NAVIGATE_PREVIOUS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   293
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   294
     * Unregisters keyboard actions.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 23697
diff changeset
   295
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    protected void uninstallKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
      unregisterKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
      SwingUtilities.replaceUIInputMap(desktop, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                                     WHEN_IN_FOCUSED_WINDOW, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      SwingUtilities.replaceUIInputMap(desktop, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                     WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
      SwingUtilities.replaceUIActionMap(desktop, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    public void paint(Graphics g, JComponent c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    public Dimension getPreferredSize(JComponent c) {return null;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    public Dimension getMinimumSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        return minSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public Dimension getMaximumSize(JComponent c){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        return maxSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Returns the <code>PropertyChangeListener</code> to install on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * the <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * @return The PropertyChangeListener that will be added to track
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * changes in the desktop pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    protected PropertyChangeListener createPropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    private Handler getHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            handler = new Handler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    private class Handler implements PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            String propertyName = evt.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            if ("desktopManager" == propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                installDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * The default DesktopManager installed by the UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   347
    @SuppressWarnings("serial") // JDK-implementation class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    private class BasicDesktopManager extends DefaultDesktopManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    private static class Actions extends UIAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        private static String CLOSE = "close";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        private static String ESCAPE = "escape";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        private static String MAXIMIZE = "maximize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        private static String MINIMIZE = "minimize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        private static String MOVE = "move";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        private static String RESIZE = "resize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        private static String RESTORE = "restore";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        private static String LEFT = "left";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        private static String RIGHT = "right";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        private static String UP = "up";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        private static String DOWN = "down";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        private static String SHRINK_LEFT = "shrinkLeft";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        private static String SHRINK_RIGHT = "shrinkRight";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        private static String SHRINK_UP = "shrinkUp";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        private static String SHRINK_DOWN = "shrinkDown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        private static String NEXT_FRAME = "selectNextFrame";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        private static String PREVIOUS_FRAME = "selectPreviousFrame";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        private static String NAVIGATE_NEXT = "navigateNext";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        private static String NAVIGATE_PREVIOUS = "navigatePrevious";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        private final int MOVE_RESIZE_INCREMENT = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        private static boolean moving = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        private static boolean resizing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        private static JInternalFrame sourceFrame = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        private static Component focusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        Actions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            super(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        Actions(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            JDesktopPane dp = (JDesktopPane)e.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            String key = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                    RESTORE == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                setState(dp, key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            else if (ESCAPE == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                if (sourceFrame == dp.getSelectedFrame() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                        focusOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    focusOwner.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                moving = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                resizing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                sourceFrame = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                focusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            else if (MOVE == key || RESIZE == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                sourceFrame = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                if (sourceFrame == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                moving = (key == MOVE) ? true : false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                resizing = (key == RESIZE) ? true : false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                focusOwner = KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                    getCurrentKeyboardFocusManager().getFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                    focusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                sourceFrame.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            else if (LEFT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                     RIGHT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                     UP == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                     DOWN == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                     SHRINK_RIGHT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                     SHRINK_LEFT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                     SHRINK_UP == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                     SHRINK_DOWN == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                JInternalFrame c = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                if (sourceFrame == null || c != sourceFrame ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                        KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                            getCurrentKeyboardFocusManager().getFocusOwner() !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                sourceFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                Insets minOnScreenInsets =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    UIManager.getInsets("Desktop.minOnScreenInsets");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                Dimension size = c.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                Dimension minSize = c.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                int dpWidth = dp.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                int dpHeight = dp.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                int delta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                Point loc = c.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                if (LEFT == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        c.setLocation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                loc.x + size.width - MOVE_RESIZE_INCREMENT <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                    minOnScreenInsets.right ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                                        -size.width + minOnScreenInsets.right :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                        loc.x - MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                        c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                        c.setSize(size.width + MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                                size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                } else if (RIGHT == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                        c.setLocation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                                loc.x + MOVE_RESIZE_INCREMENT >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                                    dpWidth - minOnScreenInsets.left ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                                        dpWidth - minOnScreenInsets.left :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                                        loc.x + MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                                loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                        c.setSize(size.width + MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                                size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                } else if (UP == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                        c.setLocation(loc.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                loc.y + size.height - MOVE_RESIZE_INCREMENT <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                                    minOnScreenInsets.bottom ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                        -size.height +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                            minOnScreenInsets.bottom :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                                        loc.y - MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                        c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                        c.setSize(size.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                                size.height + MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                } else if (DOWN == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                        c.setLocation(loc.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                                loc.y + MOVE_RESIZE_INCREMENT >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                                    dpHeight - minOnScreenInsets.top ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                                        dpHeight - minOnScreenInsets.top :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                                        loc.y + MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                        c.setSize(size.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                                size.height + MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                } else if (SHRINK_LEFT == key && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                    if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                        delta = size.width - minSize.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                    if (loc.x + size.width - delta < minOnScreenInsets.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                        delta = loc.x + size.width - minOnScreenInsets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                    c.setSize(size.width - delta, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                } else if (SHRINK_RIGHT == key && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                    if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                        delta = size.width - minSize.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                    if (loc.x + delta > dpWidth - minOnScreenInsets.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                        delta = (dpWidth - minOnScreenInsets.right) - loc.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                    c.setLocation(loc.x + delta, loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    c.setSize(size.width - delta, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                } else if (SHRINK_UP == key && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                    if (minSize.height <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                            (size.height - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                        delta = size.height - minSize.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                    if (loc.y + size.height - delta <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                            minOnScreenInsets.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                        delta = loc.y + size.height - minOnScreenInsets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                    c.setSize(size.width, size.height - delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                } else if (SHRINK_DOWN == key  && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                    if (minSize.height <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                            (size.height - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                        delta = size.height - minSize.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                    if (loc.y + delta > dpHeight - minOnScreenInsets.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                        delta = (dpHeight - minOnScreenInsets.top) - loc.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    c.setLocation(loc.x, loc.y + delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                    c.setSize(size.width, size.height - delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                dp.selectFrame((key == NEXT_FRAME) ? true : false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            else if (NAVIGATE_NEXT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                     NAVIGATE_PREVIOUS == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                boolean moveForward = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                if (NAVIGATE_PREVIOUS == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                    moveForward = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                Container cycleRoot = dp.getFocusCycleRootAncestor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                if (cycleRoot != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                    FocusTraversalPolicy policy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                        cycleRoot.getFocusTraversalPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                    if (policy != null && policy instanceof
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                            SortingFocusTraversalPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                        SortingFocusTraversalPolicy sPolicy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                            (SortingFocusTraversalPolicy)policy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                        boolean idc = sPolicy.getImplicitDownCycleTraversal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                            sPolicy.setImplicitDownCycleTraversal(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                            if (moveForward) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                                KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                                    getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                                        focusNextComponent(dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                                KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                                    getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                                    focusPreviousComponent(dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                            sPolicy.setImplicitDownCycleTraversal(idc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        private void setState(JDesktopPane dp, String state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            if (state == CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                f.doDefaultCloseAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            } else if (state == MAXIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                // maximize the selected frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                if (!f.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                    if (f.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                            f.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                            f.setMaximum(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                        } catch (PropertyVetoException pve) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                            f.setMaximum(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                        } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            } else if (state == MINIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                // minimize the selected frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                if (!f.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                        f.setIcon(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                    } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            } else if (state == RESTORE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                // restore the selected minimized or maximized frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                    if (f.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                        f.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                    } else if (f.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                        f.setMaximum(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                    f.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        public boolean isEnabled(Object sender) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            if (sender instanceof JDesktopPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                JDesktopPane dp = (JDesktopPane)sender;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                String action = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                if (action == Actions.NEXT_FRAME ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                    action == Actions.PREVIOUS_FRAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                JInternalFrame iFrame = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                if (iFrame == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                } else if (action == Actions.CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                    return iFrame.isClosable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                } else if (action == Actions.MINIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                    return iFrame.isIconifiable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                } else if (action == Actions.MAXIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                    return iFrame.isMaximizable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Handles restoring a minimized or maximized internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   676
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    protected class OpenAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            SHARED_ACTION.setState(dp, Actions.RESTORE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * Handles closing an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   691
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    protected class CloseAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            SHARED_ACTION.setState(dp, Actions.CLOSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            JInternalFrame iFrame = desktop.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            if (iFrame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                return iFrame.isClosable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * Handles minimizing an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   710
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    protected class MinimizeAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            SHARED_ACTION.setState(dp, Actions.MINIMIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            JInternalFrame iFrame = desktop.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            if (iFrame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                return iFrame.isIconifiable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * Handles maximizing an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   729
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    protected class MaximizeAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            SHARED_ACTION.setState(dp, Actions.MAXIMIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            JInternalFrame iFrame = desktop.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            if (iFrame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                return iFrame.isMaximizable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * Handles navigating to the next internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   748
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    protected class NavigateAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            dp.selectFrame(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
}