jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java
author darcy
Wed, 02 Jul 2014 23:03:27 -0700
changeset 25565 ce603b34c98d
parent 23010 6dadb192ad81
child 26012 36ecb579dbc8
permissions -rw-r--r--
8043548: Fix raw and unchecked lint warnings in javax.swing.plaf.* 8042849: Fix raw and unchecked warnings in com.sun.java.swing Reviewed-by: pchelko, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21278
diff changeset
     2
 * Copyright (c) 1997, 2013, 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: 3345
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: 3345
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: 3345
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3345
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3345
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 java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.swing.DefaultLookup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.swing.UIAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
    38
 * A basic L&F implementation of JInternalFrame.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author Rich Schiavi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class BasicInternalFrameUI extends InternalFrameUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    protected JInternalFrame frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Handler handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    protected MouseInputAdapter          borderListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    protected PropertyChangeListener     propertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    protected LayoutManager              internalFrameLayout;
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
    52
    protected ComponentListener          componentListener;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    protected MouseInputListener         glassPaneDispatcher;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private InternalFrameListener        internalFrameListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    protected JComponent northPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected JComponent southPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected JComponent westPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    protected JComponent eastPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected BasicInternalFrameTitlePane titlePane; // access needs this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static DesktopManager sharedDesktopManager;
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
    64
    private boolean componentListenerAdded = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private Rectangle parentBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private boolean dragging = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private boolean resizing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
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 Java 2 platform v1.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 openMenuKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private boolean keyBindingRegistered = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private boolean keyBindingActive = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
/////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
// ComponentUI Interface Implementation methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
/////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public static ComponentUI createUI(JComponent b)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        return new BasicInternalFrameUI((JInternalFrame)b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public BasicInternalFrameUI(JInternalFrame b)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        LookAndFeel laf = UIManager.getLookAndFeel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        if (laf instanceof BasicLookAndFeel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            ((BasicLookAndFeel)laf).installAWTEventListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public void installUI(JComponent c)   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        frame = (JInternalFrame)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        installDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        installComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        LookAndFeel.installProperty(frame, "opaque", Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public void uninstallUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        if(c != frame)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            throw new IllegalComponentStateException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                this + " was asked to deinstall() "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                + c + " when it only knows about "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                + frame + ".");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        uninstallComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        updateFrameCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        handler = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        frame = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    protected void installDefaults(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        Icon frameIcon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (frameIcon == null || frameIcon instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        // Enable the content pane to inherit background color from its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        // parent by setting its background color to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        Container contentPane = frame.getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (contentPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
          Color bg = contentPane.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
          if (bg instanceof UIResource)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            contentPane.setBackground(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        frame.setLayout(internalFrameLayout = createLayoutManager());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        frame.setBackground(UIManager.getLookAndFeelDefaults().getColor("control"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        LookAndFeel.installBorder(frame, "InternalFrame.border");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    protected void installKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        createInternalFrameListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (internalFrameListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            frame.addInternalFrameListener(internalFrameListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        LazyActionMap.installLazyActionMap(frame, BasicInternalFrameUI.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            "InternalFrame.actionMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    static void loadActionMap(LazyActionMap map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        map.put(new UIAction("showSystemMenu") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                JInternalFrame iFrame = (JInternalFrame)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                if (iFrame.getUI() instanceof BasicInternalFrameUI) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    JComponent comp = ((BasicInternalFrameUI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                        iFrame.getUI()).getNorthPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    if (comp instanceof BasicInternalFrameTitlePane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                        ((BasicInternalFrameTitlePane)comp).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                            showSystemMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            public boolean isEnabled(Object sender){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                if (sender instanceof JInternalFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    JInternalFrame iFrame = (JInternalFrame)sender;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    if (iFrame.getUI() instanceof BasicInternalFrameUI) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                        return ((BasicInternalFrameUI)iFrame.getUI()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                            isKeyBindingActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // Set the ActionMap's parent to the Auditory Feedback Action Map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        BasicLookAndFeel.installAudioActionMap(map);
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 installComponents(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        setNorthPane(createNorthPane(frame));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        setSouthPane(createSouthPane(frame));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        setEastPane(createEastPane(frame));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        setWestPane(createWestPane(frame));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        borderListener = createBorderListener(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        propertyChangeListener = createPropertyChangeListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        frame.addPropertyChangeListener(propertyChangeListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        installMouseHandlers(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        glassPaneDispatcher = createGlassPaneDispatcher();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if (glassPaneDispatcher != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            frame.getGlassPane().addMouseListener(glassPaneDispatcher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            frame.getGlassPane().addMouseMotionListener(glassPaneDispatcher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   207
        componentListener =  createComponentListener();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        if (frame.getParent() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
          parentBounds = frame.getParent().getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        }
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   211
        if ((frame.getParent() != null) && !componentListenerAdded) {
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   212
            frame.getParent().addComponentListener(componentListener);
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   213
            componentListenerAdded = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    // Provide a FocusListener to listen for a WINDOW_LOST_FOCUS event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    // so that a resize can be cancelled if the focus is lost while resizing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    // when an Alt-Tab, modal dialog popup, iconify, dispose, or remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    // of the internal frame occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    private WindowFocusListener getWindowFocusListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    // Cancel a resize in progress by calling finishMouseReleased().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    private void cancelResize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            if (borderListener instanceof BorderListener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                ((BorderListener)borderListener).finishMouseReleased();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private Handler getHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            handler = new Handler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    InputMap getInputMap(int condition) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            return createInputMap(condition);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return null;
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 createInputMap(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
            Object[] bindings = (Object[])DefaultLookup.get(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                    frame, this, "InternalFrame.windowBindings");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            if (bindings != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                return LookAndFeel.makeComponentInputMap(frame, bindings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        Icon frameIcon = frame.getFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        if (frameIcon instanceof UIResource) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            frame.setFrameIcon(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        internalFrameLayout = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        frame.setLayout(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        LookAndFeel.uninstallBorder(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    protected void uninstallComponents(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        setNorthPane(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        setSouthPane(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        setEastPane(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        setWestPane(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        if(titlePane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            titlePane.uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        titlePane = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    protected void uninstallListeners() {
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   285
        if ((frame.getParent() != null) && componentListenerAdded) {
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   286
            frame.getParent().removeComponentListener(componentListener);
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   287
            componentListenerAdded = false;
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   288
        }
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
   289
        componentListener = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
      if (glassPaneDispatcher != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
          frame.getGlassPane().removeMouseListener(glassPaneDispatcher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
          frame.getGlassPane().removeMouseMotionListener(glassPaneDispatcher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
          glassPaneDispatcher = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
      deinstallMouseHandlers(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
      frame.removePropertyChangeListener(propertyChangeListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
      propertyChangeListener = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
      borderListener = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    protected void uninstallKeyboardActions(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        if (internalFrameListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            frame.removeInternalFrameListener(internalFrameListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        internalFrameListener = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        SwingUtilities.replaceUIInputMap(frame, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                                         WHEN_IN_FOCUSED_WINDOW, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        SwingUtilities.replaceUIActionMap(frame, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    void updateFrameCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        if (resizing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1277
diff changeset
   317
        Cursor s = frame.getLastCursor();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        if (s == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        frame.setCursor(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    protected LayoutManager createLayoutManager(){
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
    protected PropertyChangeListener createPropertyChangeListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public Dimension getPreferredSize(JComponent x)    {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1277
diff changeset
   335
        if(frame == x)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            return frame.getLayout().preferredLayoutSize(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        return new Dimension(100, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    public Dimension getMinimumSize(JComponent x)  {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1277
diff changeset
   341
        if(frame == x) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            return frame.getLayout().minimumLayoutSize(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        return new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public Dimension getMaximumSize(JComponent x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      * Installs necessary mouse handlers on <code>newPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
      * and adds it to the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
      * Reverse process for the <code>currentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    protected void replacePane(JComponent currentPane, JComponent newPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        if(currentPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            deinstallMouseHandlers(currentPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            frame.remove(currentPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        if(newPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
           frame.add(newPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
           installMouseHandlers(newPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    protected void deinstallMouseHandlers(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      c.removeMouseListener(borderListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
      c.removeMouseMotionListener(borderListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    protected void installMouseHandlers(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
      c.addMouseListener(borderListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      c.addMouseMotionListener(borderListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    protected JComponent createNorthPane(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      titlePane = new BasicInternalFrameTitlePane(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
      return titlePane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    protected JComponent createSouthPane(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    protected JComponent createWestPane(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    protected JComponent createEastPane(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    protected MouseInputAdapter createBorderListener(JInternalFrame w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        return new BorderListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    protected void createInternalFrameListener(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        internalFrameListener = getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    protected final boolean isKeyBindingRegistered(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
      return keyBindingRegistered;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    protected final void setKeyBindingRegistered(boolean b){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
      keyBindingRegistered = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public final boolean isKeyBindingActive(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
      return keyBindingActive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    protected final void setKeyBindingActive(boolean b){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
      keyBindingActive = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    protected void setupMenuOpenKey(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        // PENDING(hania): Why are these WHEN_IN_FOCUSED_WINDOWs? Shouldn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        // they be WHEN_ANCESTOR_OF_FOCUSED_COMPONENT?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        // Also, no longer registering on the desktopicon, the previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        // action did nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        SwingUtilities.replaceUIInputMap(frame,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                      JComponent.WHEN_IN_FOCUSED_WINDOW, map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        //ActionMap actionMap = getActionMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        //SwingUtilities.replaceUIActionMap(frame, actionMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    protected void setupMenuCloseKey(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public JComponent getNorthPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        return northPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    public void setNorthPane(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        if (northPane != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                northPane instanceof BasicInternalFrameTitlePane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            ((BasicInternalFrameTitlePane)northPane).uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        replacePane(northPane, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        northPane = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        if (c instanceof BasicInternalFrameTitlePane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
          titlePane = (BasicInternalFrameTitlePane)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    public JComponent getSouthPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        return southPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public void setSouthPane(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        southPane = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    public JComponent getWestPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        return westPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public void setWestPane(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        westPane = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public JComponent getEastPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        return eastPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    public void setEastPane(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        eastPane = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    public class InternalFramePropertyChangeListener implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        PropertyChangeListener {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20169
diff changeset
   480
        // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
         * Detects changes in state from the JInternalFrame and handles
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
         * actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            getHandler().propertyChange(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
  public class InternalFrameLayout implements LayoutManager {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20169
diff changeset
   494
    // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public void addLayoutComponent(String name, Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        getHandler().addLayoutComponent(name, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    public void removeLayoutComponent(Component c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        getHandler().removeLayoutComponent(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    public Dimension preferredLayoutSize(Container c)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        return getHandler().preferredLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        return getHandler().minimumLayoutSize(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    public void layoutContainer(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        getHandler().layoutContainer(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
/// DesktopManager methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /** Returns the proper DesktopManager. Calls getDesktopPane() to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
      * find the JDesktop component and returns the desktopManager from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
      * it. If this fails, it will return a default DesktopManager that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
      * should work in arbitrary parents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    protected DesktopManager getDesktopManager() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if(frame.getDesktopPane() != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
           && frame.getDesktopPane().getDesktopManager() != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            return frame.getDesktopPane().getDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        if(sharedDesktopManager == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
          sharedDesktopManager = createDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        return sharedDesktopManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    protected DesktopManager createDesktopManager(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
      return new DefaultDesktopManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * This method is called when the user wants to close the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * The <code>playCloseSound</code> Action is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    protected void closeFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        // Internal Frame Auditory Cue Activation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        BasicLookAndFeel.playSound(frame,"InternalFrame.closeSound");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        // delegate to desktop manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        getDesktopManager().closeFrame(f);
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
     * This method is called when the user wants to maximize the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * The <code>playMaximizeSound</code> Action is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    protected void maximizeFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        // Internal Frame Auditory Cue Activation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        BasicLookAndFeel.playSound(frame,"InternalFrame.maximizeSound");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        // delegate to desktop manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        getDesktopManager().maximizeFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * This method is called when the user wants to minimize the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * The <code>playRestoreDownSound</code> Action is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    protected void minimizeFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        // Internal Frame Auditory Cue Activation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        if ( ! f.isIcon() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            // This method seems to regularly get called after an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            // internal frame is iconified. Don't play this sound then.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            BasicLookAndFeel.playSound(frame,"InternalFrame.restoreDownSound");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        // delegate to desktop manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        getDesktopManager().minimizeFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * This method is called when the user wants to iconify the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * The <code>playMinimizeSound</code> Action is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    protected void iconifyFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        // Internal Frame Auditory Cue Activation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        BasicLookAndFeel.playSound(frame, "InternalFrame.minimizeSound");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        // delegate to desktop manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        getDesktopManager().iconifyFrame(f);
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
     * This method is called when the user wants to deiconify the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * The <code>playRestoreUpSound</code> Action is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    protected void deiconifyFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        // Internal Frame Auditory Cue Activation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        if ( ! f.isMaximum() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            // This method seems to regularly get called after an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            // internal frame is maximized. Don't play this sound then.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            BasicLookAndFeel.playSound(frame, "InternalFrame.restoreUpSound");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        // delegate to desktop manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        getDesktopManager().deiconifyFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /** This method is called when the frame becomes selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
      * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    protected void activateFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        getDesktopManager().activateFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /** This method is called when the frame is no longer selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
      * This action is delegated to the desktopManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    protected void deactivateFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        getDesktopManager().deactivateFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    /// Border Listener Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    /////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * Listens for border adjustments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    protected class BorderListener extends MouseInputAdapter implements SwingConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        // _x & _y are the mousePressed location in absolute coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        int _x, _y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        // __x & __y are the mousePressed location in source view's coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        int __x, __y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        Rectangle startingBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        int resizeDir;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        protected final int RESIZE_NONE  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        private boolean discardRelease = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        int resizeCornerSize = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        public void mouseClicked(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            if(e.getClickCount() > 1 && e.getSource() == getNorthPane()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                if(frame.isIconifiable() && frame.isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                    try { frame.setIcon(false); } catch (PropertyVetoException e2) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                } else if(frame.isMaximizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                    if(!frame.isMaximum())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                        try { frame.setMaximum(true); } catch (PropertyVetoException e2) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                        try { frame.setMaximum(false); } catch (PropertyVetoException e3) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        // Factor out finishMouseReleased() from mouseReleased(), so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        // it can be called by cancelResize() without passing it a null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        // MouseEvent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        void finishMouseReleased() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
           if (discardRelease) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
             discardRelease = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
             return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            if (resizeDir == RESIZE_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                getDesktopManager().endDraggingFrame(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                dragging = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                // Remove the WindowFocusListener for handling a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                // WINDOW_LOST_FOCUS event with a cancelResize().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                Window windowAncestor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                    SwingUtilities.getWindowAncestor(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                if (windowAncestor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                    windowAncestor.removeWindowFocusListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                        getWindowFocusListener());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                Container c = frame.getTopLevelAncestor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                if (c instanceof RootPaneContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                    Component glassPane = ((RootPaneContainer)c).getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                    glassPane.setCursor(Cursor.getPredefinedCursor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                        Cursor.DEFAULT_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                    glassPane.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                getDesktopManager().endResizingFrame(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                resizing = false;
3104
cce457efb5d8 6557223: Resize cursor stays after fast outline-resize of JInternalFrame with JScrollPane
malenkov
parents: 1290
diff changeset
   682
                updateFrameCursor();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            _x = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            _y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            __x = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            __y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            startingBounds = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            resizeDir = RESIZE_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            // Set discardRelease to true, so that only a mousePressed()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            // which sets it to false, will allow entry to the above code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            // for finishing a resize.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            discardRelease = true;
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 void mouseReleased(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            finishMouseReleased();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        public void mousePressed(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            Point p = SwingUtilities.convertPoint((Component)e.getSource(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                        e.getX(), e.getY(), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            __x = e.getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            __y = e.getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            _x = p.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            _y = p.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            startingBounds = frame.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            resizeDir = RESIZE_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            discardRelease = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            try { frame.setSelected(true); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            catch (PropertyVetoException e1) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            Insets i = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            Point ep = new Point(__x, __y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            if (e.getSource() == getNorthPane()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                Point np = getNorthPane().getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                ep.x += np.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                ep.y += np.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            if (e.getSource() == getNorthPane()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                if (ep.x > i.left && ep.y > i.top && ep.x < frame.getWidth() - i.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                    getDesktopManager().beginDraggingFrame(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                    dragging = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            if (!frame.isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            if (e.getSource() == frame || e.getSource() == getNorthPane()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                if (ep.x <= i.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                    if (ep.y < resizeCornerSize + i.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                        resizeDir = NORTH_WEST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    } else if (ep.y > frame.getHeight()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                              - resizeCornerSize - i.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                        resizeDir = SOUTH_WEST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                        resizeDir = WEST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                } else if (ep.x >= frame.getWidth() - i.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                    if (ep.y < resizeCornerSize + i.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                        resizeDir = NORTH_EAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                    } else if (ep.y > frame.getHeight()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                              - resizeCornerSize - i.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                        resizeDir = SOUTH_EAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                        resizeDir = EAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                } else if (ep.y <= i.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                    if (ep.x < resizeCornerSize + i.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                        resizeDir = NORTH_WEST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                    } else if (ep.x > frame.getWidth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                              - resizeCornerSize - i.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                        resizeDir = NORTH_EAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                        resizeDir = NORTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                } else if (ep.y >= frame.getHeight() - i.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                    if (ep.x < resizeCornerSize + i.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                        resizeDir = SOUTH_WEST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                    } else if (ep.x > frame.getWidth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                              - resizeCornerSize - i.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                        resizeDir = SOUTH_EAST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                      resizeDir = SOUTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                  /* the mouse press happened inside the frame, not in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                     border */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                  discardRelease = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                  return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                Cursor s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                switch (resizeDir) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                case SOUTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                  s = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                case NORTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                  s = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                case WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                  s = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                case EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                  s = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                case SOUTH_EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                  s = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                case SOUTH_WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                  s = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                case NORTH_WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                  s = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                case NORTH_EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                  s = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                Container c = frame.getTopLevelAncestor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                if (c instanceof RootPaneContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                    Component glassPane = ((RootPaneContainer)c).getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                    glassPane.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                    glassPane.setCursor(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                getDesktopManager().beginResizingFrame(frame, resizeDir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                resizing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                // Add the WindowFocusListener for handling a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                // WINDOW_LOST_FOCUS event with a cancelResize().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                Window windowAncestor = SwingUtilities.getWindowAncestor(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                if (windowAncestor != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                    windowAncestor.addWindowFocusListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                        getWindowFocusListener());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        public void mouseDragged(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            if ( startingBounds == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
              // (STEVE) Yucky work around for bug ID 4106552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                 return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
            Point p = SwingUtilities.convertPoint((Component)e.getSource(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                    e.getX(), e.getY(), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            int deltaX = _x - p.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            int deltaY = _y - p.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            Dimension min = frame.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            Dimension max = frame.getMaximumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            int newX, newY, newW, newH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
            Insets i = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            // Handle a MOVE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            if (dragging) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                if (frame.isMaximum() || ((e.getModifiers() &
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                        InputEvent.BUTTON1_MASK) !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                        InputEvent.BUTTON1_MASK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                    // don't allow moving of frames if maximixed or left mouse
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                    // button was not used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                int pWidth, pHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                Dimension s = frame.getParent().getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                pWidth = s.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                pHeight = s.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                newX = startingBounds.x - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                newY = startingBounds.y - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                // Make sure we stay in-bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                if(newX + i.left <= -__x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                    newX = -__x - i.left + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                if(newY + i.top <= -__y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                    newY = -__y - i.top + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                if(newX + __x + i.right >= pWidth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    newX = pWidth - __x - i.right - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                if(newY + __y + i.bottom >= pHeight)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                    newY =  pHeight - __y - i.bottom - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                getDesktopManager().dragFrame(frame, newX, newY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            if(!frame.isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            newX = frame.getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            newY = frame.getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            newW = frame.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            newH = frame.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            parentBounds = frame.getParent().getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            switch(resizeDir) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            case RESIZE_NONE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            case NORTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                if(startingBounds.height + deltaY < min.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                    deltaY = -(startingBounds.height - min.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                else if(startingBounds.height + deltaY > max.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                    deltaY = max.height - startingBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                newX = startingBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                newY = startingBounds.y - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                newW = startingBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                newH = startingBounds.height + deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            case NORTH_EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                if(startingBounds.height + deltaY < min.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                    deltaY = -(startingBounds.height - min.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                else if(startingBounds.height + deltaY > max.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                    deltaY = max.height - startingBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                if(startingBounds.width - deltaX < min.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                    deltaX = startingBounds.width - min.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                else if(startingBounds.width - deltaX > max.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                    deltaX = -(max.width - startingBounds.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                if (startingBounds.x + startingBounds.width - deltaX >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                    parentBounds.width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                  deltaX = startingBounds.x + startingBounds.width -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                    parentBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                newX = startingBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                newY = startingBounds.y - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                newW = startingBounds.width - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                newH = startingBounds.height + deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            case EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                if(startingBounds.width - deltaX < min.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                    deltaX = startingBounds.width - min.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                else if(startingBounds.width - deltaX > max.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                    deltaX = -(max.width - startingBounds.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                if (startingBounds.x + startingBounds.width - deltaX >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                    parentBounds.width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                  deltaX = startingBounds.x + startingBounds.width -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    parentBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                newW = startingBounds.width - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                newH = startingBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            case SOUTH_EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                if(startingBounds.width - deltaX < min.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                    deltaX = startingBounds.width - min.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                else if(startingBounds.width - deltaX > max.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                    deltaX = -(max.width - startingBounds.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                if (startingBounds.x + startingBounds.width - deltaX >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                    parentBounds.width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                  deltaX = startingBounds.x + startingBounds.width -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                    parentBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                if(startingBounds.height - deltaY < min.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                    deltaY = startingBounds.height - min.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                else if(startingBounds.height - deltaY > max.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                    deltaY = -(max.height - startingBounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                if (startingBounds.y + startingBounds.height - deltaY >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                     parentBounds.height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                  deltaY = startingBounds.y + startingBounds.height -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                    parentBounds.height ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                newW = startingBounds.width - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                newH = startingBounds.height - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            case SOUTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                if(startingBounds.height - deltaY < min.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                    deltaY = startingBounds.height - min.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                else if(startingBounds.height - deltaY > max.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                    deltaY = -(max.height - startingBounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                if (startingBounds.y + startingBounds.height - deltaY >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                     parentBounds.height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                  deltaY = startingBounds.y + startingBounds.height -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                    parentBounds.height ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                newW = startingBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                newH = startingBounds.height - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            case SOUTH_WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                if(startingBounds.height - deltaY < min.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                    deltaY = startingBounds.height - min.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                else if(startingBounds.height - deltaY > max.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                    deltaY = -(max.height - startingBounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                if (startingBounds.y + startingBounds.height - deltaY >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                     parentBounds.height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                  deltaY = startingBounds.y + startingBounds.height -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                    parentBounds.height ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                if(startingBounds.width + deltaX < min.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                    deltaX = -(startingBounds.width - min.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                else if(startingBounds.width + deltaX > max.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                    deltaX = max.width - startingBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                if (startingBounds.x - deltaX < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                  deltaX = startingBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                newX = startingBounds.x - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                newY = startingBounds.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                newW = startingBounds.width + deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                newH = startingBounds.height - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            case WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                if(startingBounds.width + deltaX < min.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                    deltaX = -(startingBounds.width - min.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                else if(startingBounds.width + deltaX > max.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                    deltaX = max.width - startingBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                if (startingBounds.x - deltaX < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                  deltaX = startingBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                newX = startingBounds.x - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                newY = startingBounds.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                newW = startingBounds.width + deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                newH = startingBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            case NORTH_WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                if(startingBounds.width + deltaX < min.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                    deltaX = -(startingBounds.width - min.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                else if(startingBounds.width + deltaX > max.width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                    deltaX = max.width - startingBounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                if (startingBounds.x - deltaX < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                  deltaX = startingBounds.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                if(startingBounds.height + deltaY < min.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                    deltaY = -(startingBounds.height - min.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                else if(startingBounds.height + deltaY > max.height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                    deltaY = max.height - startingBounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                newX = startingBounds.x - deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                newY = startingBounds.y - deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                newW = startingBounds.width + deltaX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
                newH = startingBounds.height + deltaY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            getDesktopManager().resizeFrame(frame, newX, newY, newW, newH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        public void mouseMoved(MouseEvent e)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            if(!frame.isResizable())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
            if (e.getSource() == frame || e.getSource() == getNorthPane()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                Insets i = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                Point ep = new Point(e.getX(), e.getY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                if (e.getSource() == getNorthPane()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                    Point np = getNorthPane().getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                    ep.x += np.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                    ep.y += np.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                if(ep.x <= i.left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                    if(ep.y < resizeCornerSize + i.top)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                    else if(ep.y > frame.getHeight() - resizeCornerSize - i.bottom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                } else if(ep.x >= frame.getWidth() - i.right) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                    if(e.getY() < resizeCornerSize + i.top)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                    else if(ep.y > frame.getHeight() - resizeCornerSize - i.bottom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                } else if(ep.y <= i.top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                    if(ep.x < resizeCornerSize + i.left)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                    else if(ep.x > frame.getWidth() - resizeCornerSize - i.right)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                } else if(ep.y >= frame.getHeight() - i.bottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                    if(ep.x < resizeCornerSize + i.left)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                    else if(ep.x > frame.getWidth() - resizeCornerSize - i.right)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                        frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                    updateFrameCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            updateFrameCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        public void mouseEntered(MouseEvent e)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
            updateFrameCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        public void mouseExited(MouseEvent e)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            updateFrameCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1277
diff changeset
  1093
    }    /// End BorderListener Class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    protected class ComponentHandler implements ComponentListener {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20169
diff changeset
  1096
      // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
      // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
      // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
      // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
      /** Invoked when a JInternalFrame's parent's size changes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
      public void componentResized(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
          getHandler().componentResized(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
      public void componentMoved(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
          getHandler().componentMoved(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
      public void componentShown(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
          getHandler().componentShown(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
      public void componentHidden(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
          getHandler().componentHidden(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    protected ComponentListener createComponentListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
      return getHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    protected class GlassPaneDispatcher implements MouseInputListener {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20169
diff changeset
  1122
        // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        public void mousePressed(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
            getHandler().mousePressed(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        public void mouseEntered(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
            getHandler().mouseEntered(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        public void mouseMoved(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            getHandler().mouseMoved(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
        public void mouseExited(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
            getHandler().mouseExited(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        public void mouseClicked(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            getHandler().mouseClicked(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        public void mouseReleased(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            getHandler().mouseReleased(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        public void mouseDragged(MouseEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            getHandler().mouseDragged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
    protected MouseInputListener createGlassPaneDispatcher() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    protected class BasicInternalFrameListener implements InternalFrameListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    {
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20169
diff changeset
  1162
      // NOTE: This class exists only for backward compatibility. All
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
      // its functionality has been moved into Handler. If you need to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
      // new functionality add it to the Handler, but make sure this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
      // class calls into the Handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
      public void internalFrameClosing(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
          getHandler().internalFrameClosing(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
      public void internalFrameClosed(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
          getHandler().internalFrameClosed(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
      public void internalFrameOpened(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
          getHandler().internalFrameOpened(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
      public void internalFrameIconified(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
          getHandler().internalFrameIconified(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
      public void internalFrameDeiconified(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
          getHandler().internalFrameDeiconified(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
      public void internalFrameActivated(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
          getHandler().internalFrameActivated(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
      public void internalFrameDeactivated(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
          getHandler().internalFrameDeactivated(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
    private class Handler implements ComponentListener, InternalFrameListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
            LayoutManager, MouseInputListener, PropertyChangeListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
            WindowFocusListener, SwingConstants {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        public void windowGainedFocus(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        public void windowLostFocus(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
            // Cancel a resize which may be in progress, when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
            // WINDOW_LOST_FOCUS event occurs, which may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
            // caused by an Alt-Tab or a modal dialog popup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
            cancelResize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        // ComponentHandler methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        /** Invoked when a JInternalFrame's parent's size changes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        public void componentResized(ComponentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            // Get the JInternalFrame's parent container size
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
            Rectangle parentNewBounds = ((Component) e.getSource()).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            JInternalFrame.JDesktopIcon icon = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
            if (frame != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                icon = frame.getDesktopIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                // Resize the internal frame if it is maximized and relocate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                // the associated icon as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                if (frame.isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                    frame.setBounds(0, 0, parentNewBounds.width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                        parentNewBounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1227
            // Relocate the icon base on the new parent bounds.
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1228
            if (icon != null) {
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1229
                Rectangle iconBounds = icon.getBounds();
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1230
                int y = iconBounds.y +
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1231
                        (parentNewBounds.height - parentBounds.height);
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1232
                icon.setBounds(iconBounds.x, y,
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1233
                        iconBounds.width, iconBounds.height);
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1234
            }
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1235
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
            // Update the new parent bounds for next resize.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            if (!parentBounds.equals(parentNewBounds)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                parentBounds = parentNewBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
            // Validate the component tree for this container.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
            if (frame != null) frame.validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        public void componentMoved(ComponentEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        public void componentShown(ComponentEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        public void componentHidden(ComponentEvent e) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        // InternalFrameListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        public void internalFrameClosed(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
            frame.removeInternalFrameListener(getHandler());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        public void internalFrameActivated(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
            if (!isKeyBindingRegistered()){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
                setKeyBindingRegistered(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                setupMenuOpenKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                setupMenuCloseKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
            if (isKeyBindingRegistered())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                setKeyBindingActive(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        public void internalFrameDeactivated(InternalFrameEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
            setKeyBindingActive(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
        public void internalFrameClosing(InternalFrameEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        public void internalFrameOpened(InternalFrameEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
        public void internalFrameIconified(InternalFrameEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        public void internalFrameDeiconified(InternalFrameEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
        // LayoutManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
        public void addLayoutComponent(String name, Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        public void removeLayoutComponent(Component c) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        public Dimension preferredLayoutSize(Container c)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            Dimension result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
            Insets i = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
            result = new Dimension(frame.getRootPane().getPreferredSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
            result.width += i.left + i.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
            result.height += i.top + i.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
            if(getNorthPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                Dimension d = getNorthPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                result.width = Math.max(d.width, result.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                result.height += d.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
            if(getSouthPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
                Dimension d = getSouthPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                result.width = Math.max(d.width, result.width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
                result.height += d.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
            if(getEastPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
                Dimension d = getEastPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
                result.width += d.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
                result.height = Math.max(d.height, result.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
            if(getWestPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
                Dimension d = getWestPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
                result.width += d.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
                result.height = Math.max(d.height, result.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
        public Dimension minimumLayoutSize(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
            // The minimum size of the internal frame only takes into
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
            // account the title pane since you are allowed to resize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
            // the frames to the point where just the title pane is visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
            Dimension result = new Dimension();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
            if (getNorthPane() != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
                getNorthPane() instanceof BasicInternalFrameTitlePane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
                  result = new Dimension(getNorthPane().getMinimumSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
            Insets i = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
            result.width += i.left + i.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
            result.height += i.top + i.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
        public void layoutContainer(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
            Insets i = frame.getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
            int cx, cy, cw, ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
            cx = i.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
            cy = i.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
            cw = frame.getWidth() - i.left - i.right;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
            ch = frame.getHeight() - i.top - i.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
            if(getNorthPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
                Dimension size = getNorthPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
                if (DefaultLookup.getBoolean(frame, BasicInternalFrameUI.this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
                          "InternalFrame.layoutTitlePaneAtOrigin", false)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
                    cy = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
                    ch += i.top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
                    getNorthPane().setBounds(0, 0, frame.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                                             size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
                    getNorthPane().setBounds(cx, cy, cw, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
                cy += size.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
                ch -= size.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
            if(getSouthPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
                Dimension size = getSouthPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
                getSouthPane().setBounds(cx, frame.getHeight()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
                                                    - i.bottom - size.height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
                                                    cw, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
                ch -= size.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
            if(getWestPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
                Dimension size = getWestPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
                getWestPane().setBounds(cx, cy, size.width, ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
                cw -= size.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
                cx += size.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
            if(getEastPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
                Dimension size = getEastPane().getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
                getEastPane().setBounds(cw - size.width, cy, size.width, ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
                cw -= size.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
            if(frame.getRootPane() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
                frame.getRootPane().setBounds(cx, cy, cw, ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
        // MouseInputListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
        public void mousePressed(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
        public void mouseEntered(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
        public void mouseMoved(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
        public void mouseExited(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
        public void mouseClicked(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
        public void mouseReleased(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
        public void mouseDragged(MouseEvent e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        // PropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        public void propertyChange(PropertyChangeEvent evt) {
1290
da8902cd496c 6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents: 1277
diff changeset
  1397
            String prop = evt.getPropertyName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
            JInternalFrame f = (JInternalFrame)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
            Object newValue = evt.getNewValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            Object oldValue = evt.getOldValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
            if (JInternalFrame.IS_CLOSED_PROPERTY == prop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
                if (newValue == Boolean.TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                    // Cancel a resize in progress if the internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
                    // gets a setClosed(true) or dispose().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                    cancelResize();
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1407
                    if ((frame.getParent() != null) && componentListenerAdded) {
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1408
                        frame.getParent().removeComponentListener(componentListener);
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1409
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
                    closeFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            } else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
                if(newValue == Boolean.TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
                    maximizeFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
                    minimizeFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
            } else if(JInternalFrame.IS_ICON_PROPERTY == prop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
                if (newValue == Boolean.TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
                    iconifyFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                    deiconifyFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
            } else if (JInternalFrame.IS_SELECTED_PROPERTY == prop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
                if (newValue == Boolean.TRUE && oldValue == Boolean.FALSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                    activateFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
                } else if (newValue == Boolean.FALSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
                           oldValue == Boolean.TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
                    deactivateFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
            } else if (prop == "ancestor") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
                if (newValue == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
                    // Cancel a resize in progress, if the internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
                    // gets a remove(), removeNotify() or setIcon(true).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                    cancelResize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
                if (frame.getParent() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
                    parentBounds = f.getParent().getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                    parentBounds = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
                }
3345
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1442
                if ((frame.getParent() != null) && !componentListenerAdded) {
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1443
                    f.getParent().addComponentListener(componentListener);
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1444
                    componentListenerAdded = true;
e095f8b1c3e8 6802868: JInternalFrame is not maximized when maximized parent frame.
malenkov
parents: 3104
diff changeset
  1445
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
            } else if (JInternalFrame.TITLE_PROPERTY == prop ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                    prop == "closable" || prop == "iconable" ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                    prop == "maximizable") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                Dimension dim = frame.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                Dimension frame_dim = frame.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                if (dim.width > frame_dim.width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                    frame.setSize(dim.width, frame_dim.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
}