jdk/src/share/classes/javax/swing/plaf/basic/BasicDesktopPaneUI.java
author darcy
Sun, 23 Mar 2014 13:49:48 -0700
changeset 23697 e556a715949f
parent 23010 6dadb192ad81
child 25761 c408b10ef757
permissions -rw-r--r--
8034169: Fix serial lint warnings in javax.swing Reviewed-by: alanb, prr
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&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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected JDesktopPane desktop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    protected DesktopManager desktopManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected KeyStroke minimizeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    protected KeyStroke maximizeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected KeyStroke closeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    protected KeyStroke navigateKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * As of Java 2 platform v1.3 this previously undocumented field is no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Key bindings are now defined by the LookAndFeel, please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @deprecated As of 1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    protected KeyStroke navigateKey2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public static ComponentUI createUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return new BasicDesktopPaneUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public BasicDesktopPaneUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public void installUI(JComponent c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        desktop = (JDesktopPane)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        installDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public void uninstallUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        uninstallDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        desktop = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        handler = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (desktop.getBackground() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            desktop.getBackground() instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            desktop.setBackground(UIManager.getColor("Desktop.background"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        LookAndFeel.installProperty(desktop, "opaque", Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    protected void uninstallDefaults() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Installs the <code>PropertyChangeListener</code> returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <code>createPropertyChangeListener</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @see #createPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        pcl = createPropertyChangeListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        desktop.addPropertyChangeListener(pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Uninstalls the <code>PropertyChangeListener</code> returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <code>createPropertyChangeListener</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @see #createPropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        desktop.removePropertyChangeListener(pcl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        pcl = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    protected void installDesktopManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        desktopManager = desktop.getDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if(desktopManager == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            desktopManager = new BasicDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            desktop.setDesktopManager(desktopManager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    protected void uninstallDesktopManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if(desktop.getDesktopManager() instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            desktop.setDesktopManager(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        desktopManager = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    protected void installKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        if (inputMap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            SwingUtilities.replaceUIInputMap(desktop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                        JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (inputMap != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            SwingUtilities.replaceUIInputMap(desktop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                        inputMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        LazyActionMap.installLazyActionMap(desktop, BasicDesktopPaneUI.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                "DesktopPane.actionMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        registerKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    protected void registerKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    protected void unregisterKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    InputMap getInputMap(int condition) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            return createInputMap(condition);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        else if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            return (InputMap)DefaultLookup.get(desktop, this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                    "Desktop.ancestorInputMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    InputMap createInputMap(int condition) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            Object[] bindings = (Object[])DefaultLookup.get(desktop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    this, "Desktop.windowBindings");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            if (bindings != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                return LookAndFeel.makeComponentInputMap(desktop, bindings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    static void loadActionMap(LazyActionMap map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        map.put(new Actions(Actions.RESTORE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        map.put(new Actions(Actions.CLOSE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        map.put(new Actions(Actions.MOVE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        map.put(new Actions(Actions.RESIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        map.put(new Actions(Actions.LEFT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        map.put(new Actions(Actions.SHRINK_LEFT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        map.put(new Actions(Actions.RIGHT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        map.put(new Actions(Actions.SHRINK_RIGHT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        map.put(new Actions(Actions.UP));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        map.put(new Actions(Actions.SHRINK_UP));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        map.put(new Actions(Actions.DOWN));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        map.put(new Actions(Actions.SHRINK_DOWN));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        map.put(new Actions(Actions.ESCAPE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        map.put(new Actions(Actions.MINIMIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        map.put(new Actions(Actions.MAXIMIZE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        map.put(new Actions(Actions.NEXT_FRAME));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        map.put(new Actions(Actions.PREVIOUS_FRAME));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        map.put(new Actions(Actions.NAVIGATE_NEXT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        map.put(new Actions(Actions.NAVIGATE_PREVIOUS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    protected void uninstallKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
      unregisterKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
      SwingUtilities.replaceUIInputMap(desktop, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                     WHEN_IN_FOCUSED_WINDOW, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
      SwingUtilities.replaceUIInputMap(desktop, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                     WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
      SwingUtilities.replaceUIActionMap(desktop, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public void paint(Graphics g, JComponent c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    public Dimension getPreferredSize(JComponent c) {return null;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    public Dimension getMinimumSize(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        return minSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public Dimension getMaximumSize(JComponent c){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return maxSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Returns the <code>PropertyChangeListener</code> to install on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * the <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @return The PropertyChangeListener that will be added to track
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * changes in the desktop pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    protected PropertyChangeListener createPropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    private Handler getHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            handler = new Handler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    private class Handler implements PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            String propertyName = evt.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            if ("desktopManager" == propertyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                installDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * The default DesktopManager installed by the UI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   307
    @SuppressWarnings("serial") // JDK-implementation class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    private class BasicDesktopManager extends DefaultDesktopManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            implements UIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private static class Actions extends UIAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        private static String CLOSE = "close";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        private static String ESCAPE = "escape";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        private static String MAXIMIZE = "maximize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        private static String MINIMIZE = "minimize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        private static String MOVE = "move";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        private static String RESIZE = "resize";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        private static String RESTORE = "restore";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        private static String LEFT = "left";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        private static String RIGHT = "right";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        private static String UP = "up";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        private static String DOWN = "down";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        private static String SHRINK_LEFT = "shrinkLeft";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        private static String SHRINK_RIGHT = "shrinkRight";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        private static String SHRINK_UP = "shrinkUp";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        private static String SHRINK_DOWN = "shrinkDown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        private static String NEXT_FRAME = "selectNextFrame";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        private static String PREVIOUS_FRAME = "selectPreviousFrame";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        private static String NAVIGATE_NEXT = "navigateNext";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        private static String NAVIGATE_PREVIOUS = "navigatePrevious";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        private final int MOVE_RESIZE_INCREMENT = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        private static boolean moving = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        private static boolean resizing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        private static JInternalFrame sourceFrame = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        private static Component focusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        Actions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            super(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        Actions(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            JDesktopPane dp = (JDesktopPane)e.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            String key = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                    RESTORE == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                setState(dp, key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            else if (ESCAPE == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                if (sourceFrame == dp.getSelectedFrame() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                        focusOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                    focusOwner.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                moving = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                resizing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                sourceFrame = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                focusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            else if (MOVE == key || RESIZE == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                sourceFrame = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                if (sourceFrame == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                moving = (key == MOVE) ? true : false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                resizing = (key == RESIZE) ? true : false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                focusOwner = KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                    getCurrentKeyboardFocusManager().getFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                    focusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                sourceFrame.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            else if (LEFT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                     RIGHT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                     UP == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                     DOWN == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                     SHRINK_RIGHT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                     SHRINK_LEFT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                     SHRINK_UP == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                     SHRINK_DOWN == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                JInternalFrame c = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                if (sourceFrame == null || c != sourceFrame ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                        KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                            getCurrentKeyboardFocusManager().getFocusOwner() !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                sourceFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                Insets minOnScreenInsets =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                    UIManager.getInsets("Desktop.minOnScreenInsets");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                Dimension size = c.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                Dimension minSize = c.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                int dpWidth = dp.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                int dpHeight = dp.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                int delta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                Point loc = c.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                if (LEFT == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                        c.setLocation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                                loc.x + size.width - MOVE_RESIZE_INCREMENT <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                                    minOnScreenInsets.right ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                                        -size.width + minOnScreenInsets.right :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                                        loc.x - MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                                loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                        c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                        c.setSize(size.width + MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                } else if (RIGHT == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                        c.setLocation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                                loc.x + MOVE_RESIZE_INCREMENT >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                                    dpWidth - minOnScreenInsets.left ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                        dpWidth - minOnScreenInsets.left :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                                        loc.x + MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                                loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                        c.setSize(size.width + MOVE_RESIZE_INCREMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                                size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                } else if (UP == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                        c.setLocation(loc.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                loc.y + size.height - MOVE_RESIZE_INCREMENT <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                    minOnScreenInsets.bottom ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                                        -size.height +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                            minOnScreenInsets.bottom :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                        loc.y - MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                        c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        c.setSize(size.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                size.height + MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                } else if (DOWN == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    if (moving) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        c.setLocation(loc.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                                loc.y + MOVE_RESIZE_INCREMENT >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                                    dpHeight - minOnScreenInsets.top ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                        dpHeight - minOnScreenInsets.top :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                        loc.y + MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    } else if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                        c.setSize(size.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                size.height + MOVE_RESIZE_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                } else if (SHRINK_LEFT == key && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                    if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                        delta = size.width - minSize.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                    if (loc.x + size.width - delta < minOnScreenInsets.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                        delta = loc.x + size.width - minOnScreenInsets.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    c.setSize(size.width - delta, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                } else if (SHRINK_RIGHT == key && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                    if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                        delta = size.width - minSize.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                    if (loc.x + delta > dpWidth - minOnScreenInsets.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                        delta = (dpWidth - minOnScreenInsets.right) - loc.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                    c.setLocation(loc.x + delta, loc.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    c.setSize(size.width - delta, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                } else if (SHRINK_UP == key && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    if (minSize.height <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                            (size.height - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                        delta = size.height - minSize.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    if (loc.y + size.height - delta <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                            minOnScreenInsets.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                        delta = loc.y + size.height - minOnScreenInsets.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                    c.setSize(size.width, size.height - delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                } else if (SHRINK_DOWN == key  && resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                    // Make sure we don't resize less than minimum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                    if (minSize.height <
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                            (size.height - MOVE_RESIZE_INCREMENT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                        delta = MOVE_RESIZE_INCREMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                        delta = size.height - minSize.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                    // Ensure that we keep the internal frame on the desktop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                    if (loc.y + delta > dpHeight - minOnScreenInsets.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                        delta = (dpHeight - minOnScreenInsets.top) - loc.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    c.setLocation(loc.x, loc.y + delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    c.setSize(size.width, size.height - delta);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                dp.selectFrame((key == NEXT_FRAME) ? true : false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            else if (NAVIGATE_NEXT == key ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                     NAVIGATE_PREVIOUS == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                boolean moveForward = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                if (NAVIGATE_PREVIOUS == key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                    moveForward = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                Container cycleRoot = dp.getFocusCycleRootAncestor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                if (cycleRoot != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                    FocusTraversalPolicy policy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                        cycleRoot.getFocusTraversalPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                    if (policy != null && policy instanceof
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                            SortingFocusTraversalPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                        SortingFocusTraversalPolicy sPolicy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                            (SortingFocusTraversalPolicy)policy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                        boolean idc = sPolicy.getImplicitDownCycleTraversal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                            sPolicy.setImplicitDownCycleTraversal(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                            if (moveForward) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                                KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                                    getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                                        focusNextComponent(dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                                KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                                    getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                    focusPreviousComponent(dp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                            sPolicy.setImplicitDownCycleTraversal(idc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            }
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 void setState(JDesktopPane dp, String state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            if (state == CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                f.doDefaultCloseAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            } else if (state == MAXIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                // maximize the selected frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                if (!f.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                    if (f.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                            f.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                            f.setMaximum(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                        } catch (PropertyVetoException pve) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                            f.setMaximum(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                        } catch (PropertyVetoException pve) {
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
            } else if (state == MINIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                // minimize the selected frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                if (f == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                if (!f.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                        f.setIcon(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                    } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            } else if (state == RESTORE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                // restore the selected minimized or maximized frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                JInternalFrame f = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                if (f == null) {
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
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                    if (f.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                        f.setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                    } else if (f.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                        f.setMaximum(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                    f.setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        public boolean isEnabled(Object sender) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            if (sender instanceof JDesktopPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                JDesktopPane dp = (JDesktopPane)sender;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                String action = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                if (action == Actions.NEXT_FRAME ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    action == Actions.PREVIOUS_FRAME) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                JInternalFrame iFrame = dp.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                if (iFrame == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                } else if (action == Actions.CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                    return iFrame.isClosable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                } else if (action == Actions.MINIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                    return iFrame.isIconifiable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                } else if (action == Actions.MAXIMIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                    return iFrame.isMaximizable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * Handles restoring a minimized or maximized internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   636
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    protected class OpenAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            SHARED_ACTION.setState(dp, Actions.RESTORE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * Handles closing an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   651
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    protected class CloseAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            SHARED_ACTION.setState(dp, Actions.CLOSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            JInternalFrame iFrame = desktop.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            if (iFrame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                return iFrame.isClosable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * Handles minimizing an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   670
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    protected class MinimizeAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            SHARED_ACTION.setState(dp, Actions.MINIMIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            JInternalFrame iFrame = desktop.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            if (iFrame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                return iFrame.isIconifiable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * Handles maximizing an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   689
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    protected class MaximizeAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            SHARED_ACTION.setState(dp, Actions.MAXIMIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            JInternalFrame iFrame = desktop.getSelectedFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            if (iFrame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                return iFrame.isMaximizable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * Handles navigating to the next internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     */
23697
e556a715949f 8034169: Fix serial lint warnings in javax.swing
darcy
parents: 23010
diff changeset
   708
    @SuppressWarnings("serial") // Superclass is not serializable across versions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    protected class NavigateAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            JDesktopPane dp = (JDesktopPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            dp.selectFrame(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
}