jdk/src/share/classes/javax/swing/JInternalFrame.java
author malenkov
Thu, 16 Jul 2009 20:12:14 +0400
changeset 3341 9d092207230a
parent 1301 15e81207e1f2
child 5506 202f599c92aa
permissions -rw-r--r--
6505027: terminateEditOnFocusLost making problems for table in JDesktopPane Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 438
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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;
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.beans.PropertyVetoException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.event.InternalFrameEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.event.InternalFrameListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.lang.StringBuilder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.swing.SwingUtilities2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * A lightweight object that provides many of the features of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * a native frame, including dragging, closing, becoming an icon,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * resizing, title display, and support for a menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * For task-oriented documentation and examples of using internal frames,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 href="http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html" target="_top">How to Use Internal Frames</a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * a section in <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Generally,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * you add <code>JInternalFrame</code>s to a <code>JDesktopPane</code>. The UI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * delegates the look-and-feel-specific actions to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <code>DesktopManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * object maintained by the <code>JDesktopPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * The <code>JInternalFrame</code> content pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * is where you add child components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * As a conveniance <code>add</code> and its variants, <code>remove</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <code>setLayout</code> have been overridden to forward to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <code>contentPane</code> as necessary. This means you can write:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *       internalFrame.add(child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * And the child will be added to the contentPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * The content pane is actually managed by an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <code>JRootPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * which also manages a layout pane, glass pane, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * optional menu bar for the internal frame. Please see the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * documentation for a complete description of these components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * Refer to {@link javax.swing.RootPaneContainer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * for details on adding, removing and setting the <code>LayoutManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * of a <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * @see InternalFrameEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * @see JDesktopPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * @see DesktopManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * @see JInternalFrame.JDesktopIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * @author Rich Schiavi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *      attribute: isContainer true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *      attribute: containerDelegate getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *      description: A frame container which is contained within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *                   another window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
public class JInternalFrame extends JComponent implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        Accessible, WindowConstants,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private static final String uiClassID = "InternalFrameUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * The <code>JRootPane</code> instance that manages the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * content pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * and optional menu bar for this internal frame, as well as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * glass pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @see RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    protected JRootPane rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * If true then calls to <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * will be forwarded to the <code>contentPane</code>. This is initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * false, but is set to true when the <code>JInternalFrame</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    protected boolean rootPaneCheckingEnabled = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /** The frame can be closed. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    protected boolean closable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /** The frame has been closed. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    protected boolean isClosed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /** The frame can be expanded to the size of the desktop pane. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    protected boolean maximizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * The frame has been expanded to its maximum size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @see #maximizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    protected boolean isMaximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * The frame can "iconified" (shrunk down and displayed as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * an icon-image).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see JInternalFrame.JDesktopIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see #setIconifiable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    protected boolean iconable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * The frame has been iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @see #isIcon()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    protected boolean isIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /** The frame's size can be changed. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    protected boolean resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /** The frame is currently selected. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    protected boolean isSelected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /** The icon shown in the top-left corner of this internal frame. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    protected Icon frameIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /** The title displayed in this internal frame's title bar. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    protected String  title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * The icon that is displayed when this internal frame is iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @see #iconable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    protected JDesktopIcon desktopIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    private Cursor lastCursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    private boolean opened;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    private Rectangle normalBounds = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    private int defaultCloseOperation = DISPOSE_ON_CLOSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * Contains the Component that focus is to go when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * <code>restoreSubcomponentFocus</code> is invoked, that is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * <code>restoreSubcomponentFocus</code> sets this to the value returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * from <code>getMostRecentFocusOwner</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    private Component lastFocusOwner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public final static String CONTENT_PANE_PROPERTY = "contentPane";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public final static String MENU_BAR_PROPERTY = "JMenuBar";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public final static String TITLE_PROPERTY = "title";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public final static String LAYERED_PANE_PROPERTY = "layeredPane";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    public final static String ROOT_PANE_PROPERTY = "rootPane";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public final static String GLASS_PANE_PROPERTY = "glassPane";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /** Bound property name. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public final static String FRAME_ICON_PROPERTY = "frameIcon";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Constrained property name indicated that this frame has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * selected status.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public final static String IS_SELECTED_PROPERTY = "selected";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /** Constrained property name indicating that the internal frame is closed. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public final static String IS_CLOSED_PROPERTY = "closed";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /** Constrained property name indicating that the internal frame is maximized. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public final static String IS_MAXIMUM_PROPERTY = "maximum";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /** Constrained property name indicating that the internal frame is iconified. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public final static String IS_ICON_PROPERTY = "icon";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    private static final Object PROPERTY_CHANGE_LISTENER_KEY =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        new StringBuilder("InternalFramePropertyChangeListener");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    private static void addPropertyChangeListenerIfNecessary() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (AppContext.getAppContext().get(PROPERTY_CHANGE_LISTENER_KEY) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            PropertyChangeListener focusListener =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                new FocusPropertyChangeListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            AppContext.getAppContext().put(PROPERTY_CHANGE_LISTENER_KEY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                focusListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            KeyboardFocusManager.getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                addPropertyChangeListener(focusListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    private static class FocusPropertyChangeListener implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            if (e.getPropertyName() == "permanentFocusOwner") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                updateLastFocusOwner((Component)e.getNewValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private static void updateLastFocusOwner(Component component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (component != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            Component parent = component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            while (parent != null && !(parent instanceof Window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                if (parent instanceof JInternalFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                    // Update lastFocusOwner for parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                    ((JInternalFrame)parent).setLastFocusOwner(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                parent = parent.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Creates a non-resizable, non-closable, non-maximizable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * non-iconifiable <code>JInternalFrame</code> with no title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public JInternalFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        this("", false, false, false, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Creates a non-resizable, non-closable, non-maximizable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * non-iconifiable <code>JInternalFrame</code> with the specified title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Note that passing in a <code>null</code> <code>title</code> results in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * unspecified behavior and possibly an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @param title  the non-<code>null</code> <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *     to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public JInternalFrame(String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        this(title, false, false, false, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * Creates a non-closable, non-maximizable, non-iconifiable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * <code>JInternalFrame</code> with the specified title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * and resizability.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @param title      the <code>String</code> to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param resizable  if <code>true</code>, the internal frame can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public JInternalFrame(String title, boolean resizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        this(title, resizable, false, false, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Creates a non-maximizable, non-iconifiable <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * with the specified title, resizability, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * closability.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @param title      the <code>String</code> to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @param resizable  if <code>true</code>, the internal frame can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @param closable   if <code>true</code>, the internal frame can be closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    public JInternalFrame(String title, boolean resizable, boolean closable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        this(title, resizable, closable, false, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * Creates a non-iconifiable <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * with the specified title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * resizability, closability, and maximizability.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @param title       the <code>String</code> to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @param resizable   if <code>true</code>, the internal frame can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @param closable    if <code>true</code>, the internal frame can be closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @param maximizable if <code>true</code>, the internal frame can be maximized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public JInternalFrame(String title, boolean resizable, boolean closable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                          boolean maximizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        this(title, resizable, closable, maximizable, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * Creates a <code>JInternalFrame</code> with the specified title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * resizability, closability, maximizability, and iconifiability.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * All <code>JInternalFrame</code> constructors use this one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @param title       the <code>String</code> to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @param resizable   if <code>true</code>, the internal frame can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @param closable    if <code>true</code>, the internal frame can be closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @param maximizable if <code>true</code>, the internal frame can be maximized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @param iconifiable if <code>true</code>, the internal frame can be iconified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public JInternalFrame(String title, boolean resizable, boolean closable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                                boolean maximizable, boolean iconifiable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        setRootPane(createRootPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        setLayout(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        this.resizable = resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        this.closable = closable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        this.maximizable = maximizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        isMaximum = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        this.iconable = iconifiable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        isIcon = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        setRootPaneCheckingEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        desktopIcon = new JDesktopIcon(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        sun.awt.SunToolkit.checkAndSetPolicy(this, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        addPropertyChangeListenerIfNecessary();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * Called by the constructor to set up the <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @return  a new <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    protected JRootPane createRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        return new JRootPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Returns the look-and-feel object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @return the <code>InternalFrameUI</code> object that renders
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *          this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    public InternalFrameUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        return (InternalFrameUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Sets the UI delegate for this <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @param ui  the UI delegate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *  description: The UI object that implements the Component's LookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public void setUI(InternalFrameUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        boolean checkingEnabled = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            setRootPaneCheckingEnabled(checkingEnabled);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * Notification from the <code>UIManager</code> that the look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * has changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * Replaces the current UI object with the latest version from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * <code>UIManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        setUI((InternalFrameUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        if (desktopIcon != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            desktopIcon.updateUIWhenHidden();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /* This method is called if <code>updateUI</code> was called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * on the associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * JDesktopIcon.  It's necessary to avoid infinite recursion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    void updateUIWhenHidden() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        setUI((InternalFrameUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        Component[] children = getComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        if (children != null) {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 715
diff changeset
   420
            for (Component child : children) {
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 715
diff changeset
   421
                SwingUtilities.updateComponentTreeUI(child);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * Returns the name of the look-and-feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * class that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @return the string "InternalFrameUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *     description: UIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * Returns whether calls to <code>add</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @return true if <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *         are fowarded; false otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    protected boolean isRootPaneCheckingEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        return rootPaneCheckingEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * Sets whether calls to <code>add</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @param enabled  true if <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *        are forwarded, false if they should operate directly on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *        <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *      hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * description: Whether the add and setLayout methods are forwarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    protected void setRootPaneCheckingEnabled(boolean enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        rootPaneCheckingEnabled = enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * Adds the specified child <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * This method is overridden to conditionally forward calls to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * By default, children are added to the <code>contentPane</code> instead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * of the frame, refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param comp the component to be enhanced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @param constraints the constraints to be respected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @param index the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @exception IllegalArgumentException if <code>index</code> is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @exception IllegalArgumentException if adding the container's parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *                  to itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @exception IllegalArgumentException if adding a window to a container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    protected void addImpl(Component comp, Object constraints, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            getContentPane().add(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            super.addImpl(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * Removes the specified component from the container. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * <code>comp</code> is not a child of the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * this will forward the call to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @param comp the component to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @throws NullPointerException if <code>comp</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @see #add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    public void remove(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        int oldCount = getComponentCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        super.remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        if (oldCount == getComponentCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            getContentPane().remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * Ensures that, by default, the layout of this component cannot be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Overridden to conditionally forward the call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @param manager the <code>LayoutManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    public void setLayout(LayoutManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            getContentPane().setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            super.setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
//////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
/// Property Methods
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
     * Returns the current <code>JMenuBar</code> for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * <code>JInternalFrame</code>, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * if no menu bar has been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @return the current menu bar, or <code>null</code> if none has been set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @deprecated As of Swing version 1.0.3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * replaced by <code>getJMenuBar()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    public JMenuBar getMenuBar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
      return getRootPane().getMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * Returns the current <code>JMenuBar</code> for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * <code>JInternalFrame</code>, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * if no menu bar has been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * @return  the <code>JMenuBar</code> used by this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @see #setJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    public JMenuBar getJMenuBar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        return getRootPane().getJMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * Sets the <code>menuBar</code> property for this <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * @param m  the <code>JMenuBar</code> to use in this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @see #getJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @deprecated As of Swing version 1.0.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *  replaced by <code>setJMenuBar(JMenuBar m)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    public void setMenuBar(JMenuBar m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        JMenuBar oldValue = getMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        getRootPane().setJMenuBar(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        firePropertyChange(MENU_BAR_PROPERTY, oldValue, m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * Sets the <code>menuBar</code> property for this <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * @param m  the <code>JMenuBar</code> to use in this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * @see #getJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     *     preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     *     description: The menu bar for accessing pulldown menus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *                  from this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public void setJMenuBar(JMenuBar m){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        JMenuBar oldValue = getMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        getRootPane().setJMenuBar(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        firePropertyChange(MENU_BAR_PROPERTY, oldValue, m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    // implements javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * Returns the content pane for this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * @return the content pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    public Container getContentPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        return getRootPane().getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * Sets this <code>JInternalFrame</code>'s <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @param c  the content pane for this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @exception java.awt.IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     *           exception) if the content pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * @see RootPaneContainer#getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     *     description: The client area of the internal frame where child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *                  components are normally inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    public void setContentPane(Container c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        Container oldValue = getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        getRootPane().setContentPane(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        firePropertyChange(CONTENT_PANE_PROPERTY, oldValue, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * Returns the layered pane for this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @return a <code>JLayeredPane</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @see RootPaneContainer#setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * @see RootPaneContainer#getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public JLayeredPane getLayeredPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        return getRootPane().getLayeredPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * Sets this <code>JInternalFrame</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * <code>layeredPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * @param layered the <code>JLayeredPane</code> for this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @exception java.awt.IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     *           exception) if the layered pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @see RootPaneContainer#setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     *     description: The pane which holds the various desktop layers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    public void setLayeredPane(JLayeredPane layered) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        JLayeredPane oldValue = getLayeredPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        getRootPane().setLayeredPane(layered);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        firePropertyChange(LAYERED_PANE_PROPERTY, oldValue, layered);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * Returns the glass pane for this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * @return the glass pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * @see RootPaneContainer#setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    public Component getGlassPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        return getRootPane().getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * Sets this <code>JInternalFrame</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * <code>glassPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @param glass the glass pane for this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @see RootPaneContainer#getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *     description: A transparent pane used for menu rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    public void setGlassPane(Component glass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        Component oldValue = getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        getRootPane().setGlassPane(glass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        firePropertyChange(GLASS_PANE_PROPERTY, oldValue, glass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Returns the <code>rootPane</code> object for this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @return the <code>rootPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * @see RootPaneContainer#getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    public JRootPane getRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        return rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * Sets the <code>rootPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * for this <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * @param root  the new <code>JRootPane</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *     description: The root pane used by this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    protected void setRootPane(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            remove(rootPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        JRootPane oldValue = getRootPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        rootPane = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            boolean checkingEnabled = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                add(rootPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                setRootPaneCheckingEnabled(checkingEnabled);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        firePropertyChange(ROOT_PANE_PROPERTY, oldValue, root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * Sets whether this <code>JInternalFrame</code> can be closed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * some user action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @param b a boolean value, where <code>true</code> means this internal frame can be closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     *     preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     *     description: Indicates whether this internal frame can be closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    public void setClosable(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        Boolean oldValue = closable ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        closable = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        firePropertyChange("closable", oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * Returns whether this <code>JInternalFrame</code> can be closed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * some user action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * @return <code>true</code> if this internal frame can be closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    public boolean isClosable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        return closable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * Returns whether this <code>JInternalFrame</code> is currently closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * @return <code>true</code> if this internal frame is closed, <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    public boolean isClosed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        return isClosed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * Closes this internal frame if the argument is <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * Do not invoke this method with a <code>false</code> argument;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * the result of invoking <code>setClosed(false)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * is unspecified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * If the internal frame is already closed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * this method does nothing and returns immediately.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * Otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * this method begins by firing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * an <code>INTERNAL_FRAME_CLOSING</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * Then this method sets the <code>closed</code> property to <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * unless a listener vetoes the property change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * This method finishes by making the internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * invisible and unselected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * and then firing an <code>INTERNAL_FRAME_CLOSED</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * <b>Note:</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * To reuse an internal frame that has been closed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * you must add it to a container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * (even if you never removed it from its previous container).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * Typically, this container will be the <code>JDesktopPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * that previously contained the internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * @param b must be <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * @exception PropertyVetoException when the attempt to set the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     *            property is vetoed by the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @see #isClosed()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * @see #dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @see javax.swing.event.InternalFrameEvent#INTERNAL_FRAME_CLOSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     *     constrained: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     *     description: Indicates whether this internal frame has been closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    public void setClosed(boolean b) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        if (isClosed == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        Boolean oldValue = isClosed ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        if (b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        fireVetoableChange(IS_CLOSED_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        isClosed = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        if (isClosed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
          setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        firePropertyChange(IS_CLOSED_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        if (isClosed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
          dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        } else if (!opened) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
          /* this bogus -- we haven't defined what
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
             setClosed(false) means. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
          //        fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
          //            opened = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * Sets whether the <code>JInternalFrame</code> can be resized by some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * user action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @param b  a boolean, where <code>true</code> means this internal frame can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     *     preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     *     description: Determines whether this internal frame can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     *                  by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    public void setResizable(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        Boolean oldValue = resizable ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        resizable = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        firePropertyChange("resizable", oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * Returns whether the <code>JInternalFrame</code> can be resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * by some user action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * @return <code>true</code> if this internal frame can be resized, <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    public boolean isResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        // don't allow resizing when maximized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        return isMaximum ? false : resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * Sets the <code>iconable</code> property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * which must be <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * for the user to be able to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * make the <code>JInternalFrame</code> an icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * Some look and feels might not implement iconification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * they will ignore this property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * @param b  a boolean, where <code>true</code> means this internal frame can be iconified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     *     preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
               bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     *     description: Determines whether this internal frame can be iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    public void setIconifiable(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        Boolean oldValue = iconable ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        iconable = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        firePropertyChange("iconable", oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * Gets the <code>iconable</code> property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * which by default is <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @return the value of the <code>iconable</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @see #setIconifiable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    public boolean isIconifiable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        return iconable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * Returns whether the <code>JInternalFrame</code> is currently iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * @return <code>true</code> if this internal frame is iconified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    public boolean isIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        return isIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     * Iconifies or de-iconifies this internal frame,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * if the look and feel supports iconification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * If the internal frame's state changes to iconified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * this method fires an <code>INTERNAL_FRAME_ICONIFIED</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * If the state changes to de-iconified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * an <code>INTERNAL_FRAME_DEICONIFIED</code> event is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * @param b a boolean, where <code>true</code> means to iconify this internal frame and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     *          <code>false</code> means to de-iconify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * @exception PropertyVetoException when the attempt to set the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     *            property is vetoed by the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * @see InternalFrameEvent#INTERNAL_FRAME_ICONIFIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * @see InternalFrameEvent#INTERNAL_FRAME_DEICONIFIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     *     constrained: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     *     description: The image displayed when this internal frame is minimized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    public void setIcon(boolean b) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        if (isIcon == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        /* If an internal frame is being iconified before it has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
           parent, (e.g., client wants it to start iconic), create the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
           parent if possible so that we can place the icon in its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
           proper place on the desktop. I am not sure the call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
           validate() is necessary, since we are not going to display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
           this frame yet */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        firePropertyChange("ancestor", null, getParent());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        Boolean oldValue = isIcon ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        fireVetoableChange(IS_ICON_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        isIcon = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        firePropertyChange(IS_ICON_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        if (b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ICONIFIED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * Sets the <code>maximizable</code> property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * which determines whether the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * can be maximized by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     * some user action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     * Some look and feels might not support maximizing internal frames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * they will ignore this property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * @param b <code>true</code> to specify that this internal frame should be maximizable; <code>false</code> to specify that it should not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     *         bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     *     preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     *     description: Determines whether this internal frame can be maximized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    public void setMaximizable(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        Boolean oldValue = maximizable ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        maximizable = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        firePropertyChange("maximizable", oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * Gets the value of the <code>maximizable</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * @return the value of the <code>maximizable</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @see #setMaximizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    public boolean isMaximizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        return maximizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * Returns whether the <code>JInternalFrame</code> is currently maximized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * @return <code>true</code> if this internal frame is maximized, <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    public boolean isMaximum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        return isMaximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * Maximizes and restores this internal frame.  A maximized frame is resized to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * fully fit the <code>JDesktopPane</code> area associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * A restored frame's size is set to the <code>JInternalFrame</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * actual size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * @param b  a boolean, where <code>true</code> maximizes this internal frame and <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     *           restores it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * @exception PropertyVetoException when the attempt to set the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     *            property is vetoed by the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     *     constrained: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     *     description: Indicates whether this internal frame is maximized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    public void setMaximum(boolean b) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        if (isMaximum == b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        Boolean oldValue = isMaximum ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        fireVetoableChange(IS_MAXIMUM_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        /* setting isMaximum above the event firing means that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
           property listeners that, for some reason, test it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
           get it wrong... See, for example, getNormalBounds() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        isMaximum = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
        firePropertyChange(IS_MAXIMUM_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * Returns the title of the <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * @return a <code>String</code> containing this internal frame's title
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * @see #setTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
    public String getTitle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        return title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * Sets the <code>JInternalFrame</code> title. <code>title</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * may have a <code>null</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * @see #getTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * @param title  the <code>String</code> to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     *     preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     *     bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     *     description: The text displayed in the title bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    public void setTitle(String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        String oldValue = this.title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        firePropertyChange(TITLE_PROPERTY, oldValue, title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * Selects or deselects the internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * if it's showing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     * A <code>JInternalFrame</code> normally draws its title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * differently if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * the selected frame, which indicates to the user that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * internal frame has the focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * When this method changes the state of the internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * from deselected to selected, it fires an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * <code>InternalFrameEvent.INTERNAL_FRAME_ACTIVATED</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * If the change is from selected to deselected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * an <code>InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED</code> event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * is fired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * @param selected  a boolean, where <code>true</code> means this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     *                  should become selected (currently active)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     *                  and <code>false</code> means it should become deselected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * @exception PropertyVetoException when the attempt to set the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     *            property is vetoed by the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     * @see #isShowing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * @see InternalFrameEvent#INTERNAL_FRAME_ACTIVATED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * @see InternalFrameEvent#INTERNAL_FRAME_DEACTIVATED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
     *     constrained: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     *     description: Indicates whether this internal frame is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     *                  the active frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    public void setSelected(boolean selected) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
       // The InternalFrame may already be selected, but the focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
       // may be outside it, so restore the focus to the subcomponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
       // which previously had it. See Bug 4302764.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        if (selected && isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            restoreSubcomponentFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        // The internal frame or the desktop icon must be showing to allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        // selection.  We may deselect even if neither is showing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        if ((isSelected == selected) || (selected &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            (isIcon ? !desktopIcon.isShowing() : !isShowing()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        Boolean oldValue = isSelected ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        Boolean newValue = selected ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        fireVetoableChange(IS_SELECTED_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        /* We don't want to leave focus in the previously selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
           frame, so we have to set it to *something* in case it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
           doesn't get set in some other way (as if a user clicked on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
           a component that doesn't request focus).  If this call is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
           happening because the user clicked on a component that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
           want focus, then it will get transfered there later.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
           We test for parent.isShowing() above, because AWT throws a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
           NPE if you try to request focus on a lightweight before its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
           parent has been made visible */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        if (selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            restoreSubcomponentFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        isSelected = selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        firePropertyChange(IS_SELECTED_PROPERTY, oldValue, newValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        if (isSelected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * Returns whether the <code>JInternalFrame</code> is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * currently "selected" or active frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * @return <code>true</code> if this internal frame is currently selected (active)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * @see #setSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    public boolean isSelected() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        return isSelected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     * Sets an image to be displayed in the titlebar of this internal frame (usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     * in the top-left corner).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
     * This image is not the <code>desktopIcon</code> object, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
     * is the image displayed in the <code>JDesktop</code> when
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
     * this internal frame is iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
     * Passing <code>null</code> to this function is valid,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     * but the look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * can choose the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     * appropriate behavior for that situation, such as displaying no icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * or a default icon for the look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * @param icon the <code>Icon</code> to display in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
     * @see #getFrameIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     *     description: The icon shown in the top-left corner of this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
  public void setFrameIcon(Icon icon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        Icon oldIcon = frameIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        frameIcon = icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
        firePropertyChange(FRAME_ICON_PROPERTY, oldIcon, icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * Returns the image displayed in the title bar of this internal frame (usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     * in the top-left corner).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
     * @return the <code>Icon</code> displayed in the title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
     * @see #setFrameIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    public Icon getFrameIcon()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        return frameIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
      * Convenience method that moves this component to position 0 if its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
      * parent is a <code>JLayeredPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    public void moveToFront() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
        if (isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
            if (getDesktopIcon().getParent() instanceof JLayeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                ((JLayeredPane)getDesktopIcon().getParent()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                    moveToFront(getDesktopIcon());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        else if (getParent() instanceof JLayeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
            ((JLayeredPane)getParent()).moveToFront(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        }
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
      * Convenience method that moves this component to position -1 if its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
      * parent is a <code>JLayeredPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    public void moveToBack() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        if (isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
            if (getDesktopIcon().getParent() instanceof JLayeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                ((JLayeredPane)getDesktopIcon().getParent()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                    moveToBack(getDesktopIcon());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        else if (getParent() instanceof JLayeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
            ((JLayeredPane)getParent()).moveToBack(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     * Returns the last <code>Cursor</code> that was set by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     * <code>setCursor</code> method that is not a resizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     * <code>Cursor</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     * @return the last non-resizable <code>Cursor</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
    public Cursor getLastCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        return lastCursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
    public void setCursor(Cursor cursor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        if (cursor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
            lastCursor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            super.setCursor(cursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        int type = cursor.getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        if (!(type == Cursor.SW_RESIZE_CURSOR  ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
              type == Cursor.SE_RESIZE_CURSOR  ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
              type == Cursor.NW_RESIZE_CURSOR  ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
              type == Cursor.NE_RESIZE_CURSOR  ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
              type == Cursor.N_RESIZE_CURSOR   ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
              type == Cursor.S_RESIZE_CURSOR   ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
              type == Cursor.W_RESIZE_CURSOR   ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
              type == Cursor.E_RESIZE_CURSOR)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            lastCursor = cursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        super.setCursor(cursor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     * Convenience method for setting the layer attribute of this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     * @param layer  an <code>Integer</code> object specifying this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     *          frame's desktop layer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
     * @see JLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
     *     expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     *     description: Specifies what desktop layer is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
    public void setLayer(Integer layer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        if(getParent() != null && getParent() instanceof JLayeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
            // Normally we want to do this, as it causes the LayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            // to draw properly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
            JLayeredPane p = (JLayeredPane)getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
            p.setLayer(this, layer.intValue(), p.getPosition(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
             // Try to do the right thing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
             JLayeredPane.putLayer(this, layer.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
             if(getParent() != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                 getParent().repaint(getX(), getY(), getWidth(), getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     * Convenience method for setting the layer attribute of this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     * The method <code>setLayer(Integer)</code> should be used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
     * layer values predefined in <code>JLayeredPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
     * When using <code>setLayer(int)</code>, care must be taken not to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     * accidentally clash with those values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * @param layer  an integer specifying this internal frame's desktop layer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     * @see #setLayer(Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * @see JLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
     *     expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     *     description: Specifies what desktop layer is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    public void setLayer(int layer) {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  1284
      this.setLayer(Integer.valueOf(layer));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * Convenience method for getting the layer attribute of this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * @return  an <code>Integer</code> object specifying this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     *          frame's desktop layer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     * @see JLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    public int getLayer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
        return JLayeredPane.getLayer(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
      * Convenience method that searches the ancestor hierarchy for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
      * <code>JDesktop</code> instance. If <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
      * finds none, the <code>desktopIcon</code> tree is searched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
      * @return the <code>JDesktopPane</code> this internal frame belongs to,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
      *         or <code>null</code> if none is found
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
    public JDesktopPane getDesktopPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        Container p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        // Search upward for desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        p = getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        while(p != null && !(p instanceof JDesktopPane))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
            p = p.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        if(p == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
           // search its icon parent for desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
           p = getDesktopIcon().getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
           while(p != null && !(p instanceof JDesktopPane))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
                p = p.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        return (JDesktopPane)p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
     * Sets the <code>JDesktopIcon</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
     * <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
     * @param d the <code>JDesktopIcon</code> to display on the desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
     * @see #getDesktopIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     *           bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     *     description: The icon shown when this internal frame is minimized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    public void setDesktopIcon(JDesktopIcon d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
        JDesktopIcon oldValue = getDesktopIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
        desktopIcon = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
        firePropertyChange("desktopIcon", oldValue, d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
     * Returns the <code>JDesktopIcon</code> used when this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
     * <code>JInternalFrame</code> is iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
     * @return the <code>JDesktopIcon</code> displayed on the desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
     * @see #setDesktopIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
    public JDesktopIcon getDesktopIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
        return desktopIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
     * If the <code>JInternalFrame</code> is not in maximized state, returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
     * <code>getBounds()</code>; otherwise, returns the bounds that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * <code>JInternalFrame</code> would be restored to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     * @return a <code>Rectangle</code> containing the bounds of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     *          frame when in the normal state
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
    public Rectangle getNormalBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
      /* we used to test (!isMaximum) here, but since this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
         method is used by the property listener for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
         IS_MAXIMUM_PROPERTY, it ended up getting the wrong
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
         answer... Since normalBounds get set to null when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
         frame is restored, this should work better */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
      if (normalBounds != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
        return normalBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
      } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
        return getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
     * Sets the normal bounds for this internal frame, the bounds that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
     * this internal frame would be restored to from its maximized state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
     * This method is intended for use only by desktop managers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
     * @param r the bounds that this internal frame should be restored to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
    public void setNormalBounds(Rectangle r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
        normalBounds = r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     * If this <code>JInternalFrame</code> is active,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * returns the child that has focus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     * Otherwise, returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     * @return the component with focus, or <code>null</code> if no children have focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
    public Component getFocusOwner() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        if (isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
            return lastFocusOwner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     * Returns the child component of this <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
     * that will receive the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
     * focus when this <code>JInternalFrame</code> is selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
     * If this <code>JInternalFrame</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
     * currently selected, this method returns the same component as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
     * the <code>getFocusOwner</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
     * If this <code>JInternalFrame</code> is not selected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
     * then the child component that most recently requested focus will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
     * returned. If no child component has ever requested focus, then this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
     * <code>JInternalFrame</code>'s initial focusable component is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
     * If no such
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
     * child exists, then this <code>JInternalFrame</code>'s default component
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
     * to focus is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
     * @return the child component that will receive focus when this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
     *         <code>JInternalFrame</code> is selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
     * @see #getFocusOwner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
     * @see #isSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
    public Component getMostRecentFocusOwner() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
        if (isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
            return getFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
        if (lastFocusOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
            return lastFocusOwner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        FocusTraversalPolicy policy = getFocusTraversalPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        if (policy instanceof InternalFrameFocusTraversalPolicy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
            return ((InternalFrameFocusTraversalPolicy)policy).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                getInitialComponent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
        Component toFocus = policy.getDefaultComponent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        if (toFocus != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
            return toFocus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        return getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
     * Requests the internal frame to restore focus to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
     * last subcomponent that had focus. This is used by the UI when
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
     * the user selected this internal frame --
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
     * for example, by clicking on the title bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
    public void restoreSubcomponentFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
        if (isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
            SwingUtilities2.compositeRequestFocus(getDesktopIcon());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
        else {
3341
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1458
            Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1459
            if ((component == null) || !SwingUtilities.isDescendingFrom(component, this)) {
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1460
                // FocusPropertyChangeListener will eventually update
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1461
                // lastFocusOwner. As focus requests are asynchronous
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1462
                // lastFocusOwner may be accessed before it has been correctly
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1463
                // updated. To avoid any problems, lastFocusOwner is immediately
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1464
                // set, assuming the request will succeed.
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1465
                setLastFocusOwner(getMostRecentFocusOwner());
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1466
                if (lastFocusOwner == null) {
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1467
                    // Make sure focus is restored somewhere, so that
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1468
                    // we don't leave a focused component in another frame while
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1469
                    // this frame is selected.
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1470
                    setLastFocusOwner(getContentPane());
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1471
                }
9d092207230a 6505027: terminateEditOnFocusLost making problems for table in JDesktopPane
malenkov
parents: 1301
diff changeset
  1472
                lastFocusOwner.requestFocus();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
    private void setLastFocusOwner(Component component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
        lastFocusOwner = component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
     * Moves and resizes this component.  Unlike other components,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
     * this implementation also forces re-layout, so that frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
     * decorations such as the title bar are always redisplayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
     * @param x  an integer giving the component's new horizontal position
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
     *           measured in pixels from the left of its container
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
     * @param y  an integer giving the component's new vertical position,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
     *           measured in pixels from the bottom of its container
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
     * @param width  an integer giving the component's new width in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
     * @param height an integer giving the component's new height in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
    public void reshape(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
        super.reshape(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
///////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
// Frame/Window equivalents
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
///////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
     * Adds the specified listener to receive internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
     * frame events from this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
     * @param l the internal frame listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
    public void addInternalFrameListener(InternalFrameListener l) {  // remind: sync ??
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
      listenerList.add(InternalFrameListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
      // remind: needed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
      enableEvents(0);   // turn on the newEventsOnly flag in Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
     * Removes the specified internal frame listener so that it no longer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
     * receives internal frame events from this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
     * @param l the internal frame listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
    public void removeInternalFrameListener(InternalFrameListener l) {  // remind: sync??
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
      listenerList.remove(InternalFrameListener.class, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
     * Returns an array of all the <code>InternalFrameListener</code>s added
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
     * to this <code>JInternalFrame</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
     * <code>addInternalFrameListener</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
     * @return all of the <code>InternalFrameListener</code>s added or an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
     *         array if no listeners have been added
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
     * @see #addInternalFrameListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
    public InternalFrameListener[] getInternalFrameListeners() {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 715
diff changeset
  1537
        return listenerList.getListeners(InternalFrameListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
    // remind: name ok? all one method ok? need to be synchronized?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
     * Fires an internal frame event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
     * @param id  the type of the event being fired; one of the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_OPENED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_CLOSING</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_CLOSED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_ICONIFIED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_ACTIVATED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
     * <li><code>InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * If the event type is not one of the above, nothing happens.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
    protected void fireInternalFrameEvent(int id){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
      Object[] listeners = listenerList.getListenerList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
      InternalFrameEvent e = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
      for (int i = listeners.length -2; i >=0; i -= 2){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
        if (listeners[i] == InternalFrameListener.class){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
          if (e == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
            e = new InternalFrameEvent(this, id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
            //      System.out.println("InternalFrameEvent: " + e.paramString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
          switch(e.getID()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
          case InternalFrameEvent.INTERNAL_FRAME_OPENED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
            ((InternalFrameListener)listeners[i+1]).internalFrameOpened(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
          case InternalFrameEvent.INTERNAL_FRAME_CLOSING:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
            ((InternalFrameListener)listeners[i+1]).internalFrameClosing(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
          case InternalFrameEvent.INTERNAL_FRAME_CLOSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
            ((InternalFrameListener)listeners[i+1]).internalFrameClosed(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
          case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
            ((InternalFrameListener)listeners[i+1]).internalFrameIconified(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
          case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
            ((InternalFrameListener)listeners[i+1]).internalFrameDeiconified(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
          case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
            ((InternalFrameListener)listeners[i+1]).internalFrameActivated(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
          case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
            ((InternalFrameListener)listeners[i+1]).internalFrameDeactivated(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
      /* we could do it off the event, but at the moment, that's not how
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
         I'm implementing it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
      //      if (id == InternalFrameEvent.INTERNAL_FRAME_CLOSING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
      //          doDefaultCloseAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
      //      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
     * Fires an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
     * <code>INTERNAL_FRAME_CLOSING</code> event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
     * and then performs the action specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
     * the internal frame's default close operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
     * This method is typically invoked by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
     * look-and-feel-implemented action handler
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
     * for the internal frame's close button.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
     * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
     * @see javax.swing.event.InternalFrameEvent#INTERNAL_FRAME_CLOSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
    public void doDefaultCloseAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
        fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        switch(defaultCloseOperation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
          case DO_NOTHING_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
          case HIDE_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
            setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
            if (isSelected())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
                    setSelected(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
                } catch (PropertyVetoException pve) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
            /* should this activate the next frame? that's really
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
               desktopmanager's policy... */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
          case DISPOSE_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
              try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
                fireVetoableChange(IS_CLOSED_PROPERTY, Boolean.FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
                                   Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
                isClosed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
                setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
                firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
                                   Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
                dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
              } catch (PropertyVetoException pve) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
     * Sets the operation that will happen by default when
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
     * the user initiates a "close" on this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
     * The possible choices are:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
     * <dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
     * <dt><code>DO_NOTHING_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
     * <dd> Do nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
     *      This requires the program to handle the operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
     *      in the <code>windowClosing</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
     *      of a registered <code>InternalFrameListener</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
     * <dt><code>HIDE_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
     * <dd> Automatically make the internal frame invisible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
     * <dt><code>DISPOSE_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
     * <dd> Automatically dispose of the internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
     * </dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
     * The default value is <code>DISPOSE_ON_CLOSE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
     * Before performing the specified close operation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
     * the internal frame fires
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     * an <code>INTERNAL_FRAME_CLOSING</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
     * @param operation one of the following constants defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
     *                  <code>javax.swing.WindowConstants</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
     *                  (an interface implemented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
     *                  <code>JInternalFrame</code>):
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
     *                  <code>DO_NOTHING_ON_CLOSE</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
     *                  <code>HIDE_ON_CLOSE</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
     *                  <code>DISPOSE_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
     * @see #addInternalFrameListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
     * @see #getDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
     * @see #setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
     * @see #dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
     * @see InternalFrameEvent#INTERNAL_FRAME_CLOSING
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
    public void setDefaultCloseOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
        this.defaultCloseOperation = operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
    * Returns the default operation that occurs when the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
    * initiates a "close" on this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
    * @return the operation that will occur when the user closes the internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
    *         frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
    * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
    public int getDefaultCloseOperation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
        return defaultCloseOperation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
     * Causes subcomponents of this <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
     * to be laid out at their preferred size.  Internal frames that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
     * iconized or maximized are first restored and then packed.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
     * internal frame is unable to be restored its state is not changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
     * and will not be packed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
     * @see       java.awt.Window#pack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
    public void pack() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
            if (isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
                setIcon(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
            } else if (isMaximum()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
                setMaximum(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
        } catch(PropertyVetoException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
        setSize(getPreferredSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
     * If the internal frame is not visible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
     * brings the internal frame to the front,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
     * makes it visible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
     * and attempts to select it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
     * The first time the internal frame is made visible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
     * this method also fires an <code>INTERNAL_FRAME_OPENED</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
     * This method does nothing if the internal frame is already visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
     * Invoking this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
     * has the same result as invoking
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
     * <code>setVisible(true)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
     * @see #moveToFront
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
     * @see #setSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
     * @see InternalFrameEvent#INTERNAL_FRAME_OPENED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
     * @see #setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
    public void show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
        // bug 4312922
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
        if (isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
            //match the behavior of setVisible(true): do nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
        // bug 4149505
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
        if (!opened) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
          fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
          opened = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
        /* icon default visibility is false; set it to true so that it shows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
           up when user iconifies frame */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
        getDesktopIcon().setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
        toFront();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
        super.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
        if (isIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
        if (!isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
                setSelected(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
            } catch (PropertyVetoException pve) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
    public void hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
        if (isIcon()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
            getDesktopIcon().setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
        super.hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
     * Makes this internal frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
     * invisible, unselected, and closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
     * If the frame is not already closed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
     * this method fires an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
     * <code>INTERNAL_FRAME_CLOSED</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
     * The results of invoking this method are similar to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
     * <code>setClosed(true)</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
     * but <code>dispose</code> always succeeds in closing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
     * the internal frame and does not fire
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
     * an <code>INTERNAL_FRAME_CLOSING</code> event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
     * @see javax.swing.event.InternalFrameEvent#INTERNAL_FRAME_CLOSED
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
     * @see #setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
     * @see #setSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
     * @see #setClosed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
        if (isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
            setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
        if (isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
                setSelected(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
            } catch (PropertyVetoException pve) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
        if (!isClosed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
          firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE, Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
          isClosed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
        fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
     * Brings this internal frame to the front.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
     * Places this internal frame  at the top of the stacking order
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
     * and makes the corresponding adjustment to other visible internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
     * frames.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
     * @see       java.awt.Window#toFront
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
     * @see       #moveToFront
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
    public void toFront() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
        moveToFront();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
     * Sends this internal frame to the back.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
     * Places this internal frame at the bottom of the stacking order
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
     * and makes the corresponding adjustment to other visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
     * internal frames.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
     * @see       java.awt.Window#toBack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
     * @see       #moveToBack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
    public void toBack() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
        moveToBack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
     * Does nothing because <code>JInternalFrame</code>s must always be roots of a focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
     * traversal cycle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
     * @param focusCycleRoot this value is ignored
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
     * @see #isFocusCycleRoot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
     * @see java.awt.Container#setFocusTraversalPolicy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
     * @see java.awt.Container#getFocusTraversalPolicy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
    public final void setFocusCycleRoot(boolean focusCycleRoot) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
     * Always returns <code>true</code> because all <code>JInternalFrame</code>s must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
     * roots of a focus traversal cycle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
     * @return <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
     * @see #setFocusCycleRoot
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
     * @see java.awt.Container#setFocusTraversalPolicy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
     * @see java.awt.Container#getFocusTraversalPolicy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
    public final boolean isFocusCycleRoot() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
     * Always returns <code>null</code> because <code>JInternalFrame</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
     * must always be roots of a focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
     * traversal cycle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
     * @return <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
     * @see java.awt.Container#isFocusCycleRoot()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
    public final Container getFocusCycleRootAncestor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
     * Gets the warning string that is displayed with this internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
     * Since an internal frame is always secure (since it's fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
     * contained within a window that might need a warning string)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
     * this method always returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
     * @return    <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
     * @see       java.awt.Window#getWarningString
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
    public final String getWarningString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
     * See <code>readObject</code> and <code>writeObject</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
     * in <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
                boolean old = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
                    setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
                    ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
                } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
                    setRootPaneCheckingEnabled(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
    /* Called from the JComponent's EnableSerializationFocusListener to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
     * do any Swing-specific pre-serialization configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
    void compWriteObjectNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
      // need to disable rootpane checking for InternalFrame: 4172083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
      boolean old = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
      try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
        setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
        super.compWriteObjectNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
      finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
        setRootPaneCheckingEnabled(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
     * Returns a string representation of this <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
     * @return  a string representation of this <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
        String rootPaneString = (rootPane != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
                                 rootPane.toString() : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
        String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
                                                "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
        String closableString = (closable ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
        String isClosedString = (isClosed ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
        String maximizableString = (maximizable ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
        String isMaximumString = (isMaximum ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
        String iconableString = (iconable ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
        String isIconString = (isIcon ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
        String resizableString = (resizable ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
        String isSelectedString = (isSelected ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
        String frameIconString = (frameIcon != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
                                  frameIcon.toString() : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
        String titleString = (title != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
                              title : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
        String desktopIconString = (desktopIcon != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
                                    desktopIcon.toString() : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
        String openedString = (opened ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
        String defaultCloseOperationString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
        if (defaultCloseOperation == HIDE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
            defaultCloseOperationString = "HIDE_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
        } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
            defaultCloseOperationString = "DISPOSE_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
        } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
            defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
        } else defaultCloseOperationString = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
        ",closable=" + closableString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
        ",defaultCloseOperation=" + defaultCloseOperationString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
        ",desktopIcon=" + desktopIconString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
        ",frameIcon=" + frameIconString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
        ",iconable=" + iconableString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
        ",isClosed=" + isClosedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
        ",isIcon=" + isIconString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
        ",isMaximum=" + isMaximumString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
        ",isSelected=" + isSelectedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
        ",maximizable=" + maximizableString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
        ",opened=" + openedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
        ",resizable=" + resizableString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
        ",rootPane=" + rootPaneString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
        ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
        ",title=" + titleString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
    // ======= begin optimized frame dragging defence code ==============
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
    boolean isDragging = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
    boolean danger = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
     * Overridden to allow optimized painting when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
     * internal frame is being dragged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
    protected void paintComponent(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
      if (isDragging) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
        //         System.out.println("ouch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
         danger = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
      super.paintComponent(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
    // ======= end optimized frame dragging defence code ==============
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
     * Gets the <code>AccessibleContext</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
     * <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
     * For internal frames, the <code>AccessibleContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
     * takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
     * <code>AccessibleJInternalFrame</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
     * A new <code>AccessibleJInternalFrame</code> instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
     * @return an <code>AccessibleJInternalFrame</code> that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
     *         <code>AccessibleContext</code> of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
     *         <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
     * @see AccessibleJInternalFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
            accessibleContext = new AccessibleJInternalFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
     * <code>JInternalFrame</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
     * Java Accessibility API appropriate to internal frame user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
    protected class AccessibleJInternalFrame extends AccessibleJComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
        implements AccessibleValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
         * Get the accessible name of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
         * @return the localized name of the object -- can be <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
         * object does not have a name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
         * @see #setAccessibleName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
        public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
            String name = accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
            if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
                name = (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
            if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
                name = getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
            return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
            return AccessibleRole.INTERNAL_FRAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
         * Gets the AccessibleValue associated with this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
         * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
         * returns this object, which is responsible for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
         * <code>AccessibleValue</code> interface on behalf of itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
         * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
        public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
        // AccessibleValue methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
         * Get the value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
         * @return value of the object -- can be <code>null</code> if this object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
         * have a value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
        public Number getCurrentAccessibleValue() {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  2093
            return Integer.valueOf(getLayer());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
         * Set the value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
         * @return <code>true</code> if the value was set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
        public boolean setCurrentAccessibleValue(Number n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
            // TIGER - 4422535
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
            if (n == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
            setLayer(new Integer(n.intValue()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
         * Get the minimum value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
         * @return Minimum value of the object; <code>null</code> if this object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
         * have a minimum value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
        public Number getMinimumAccessibleValue() {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  2117
            return Integer.MIN_VALUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
         * Get the maximum value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
         * @return Maximum value of the object; <code>null</code> if this object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
         * have a maximum value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
        public Number getMaximumAccessibleValue() {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
  2127
            return Integer.MAX_VALUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
    } // AccessibleJInternalFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
     * This component represents an iconified version of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
     * <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
     * This API should NOT BE USED by Swing applications, as it will go
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
     * away in future versions of Swing as its functionality is moved into
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
     * <code>JInternalFrame</code>.  This class is public only so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
     * UI objects can display a desktop icon.  If an application
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
     * wants to display a desktop icon, it should create a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
     * <code>JInternalFrame</code> instance and iconify it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
     * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
     * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
     * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
    static public class JDesktopIcon extends JComponent implements Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
        JInternalFrame internalFrame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
         * Creates an icon for an internal frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
         * @param f  the <code>JInternalFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
         *              for which the icon is created
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
        public JDesktopIcon(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
            setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
            setInternalFrame(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
            updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
         * Returns the look-and-feel object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
         * @return the <code>DesktopIconUI</code> object that renders
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
         *              this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
        public DesktopIconUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
            return (DesktopIconUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
         * Sets the look-and-feel object that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
         * @param ui  the <code>DesktopIconUI</code> look-and-feel object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
         * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
        public void setUI(DesktopIconUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
            super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
         * Returns the <code>JInternalFrame</code> that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
         * <code>DesktopIcon</code> is associated with.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
         * @return the <code>JInternalFrame</code> with which this icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
         *              is associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
        public JInternalFrame getInternalFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
            return internalFrame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
         * Sets the <code>JInternalFrame</code> with which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
         * <code>DesktopIcon</code> is associated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
         * @param f  the <code>JInternalFrame</code> with which this icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
         *              is associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
        public void setInternalFrame(JInternalFrame f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
            internalFrame = f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
         * Convenience method to ask the icon for the <code>Desktop</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
         * object it belongs to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
         * @return the <code>JDesktopPane</code> that contains this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
         *           icon's internal frame, or <code>null</code> if none found
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
        public JDesktopPane getDesktopPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
            if(getInternalFrame() != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
                return getInternalFrame().getDesktopPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
         * Notification from the <code>UIManager</code> that the look and feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
         * has changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
         * Replaces the current UI object with the latest version from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
         * <code>UIManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
         * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
        public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
            boolean hadUI = (ui != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
            setUI((DesktopIconUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
            invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
            Dimension r = getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
            setSize(r.width, r.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
            if (internalFrame != null && internalFrame.getUI() != null) {  // don't do this if UI not created yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
                SwingUtilities.updateComponentTreeUI(internalFrame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
        /* This method is called if updateUI was called on the associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
         * JInternalFrame.  It's necessary to avoid infinite recursion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
        void updateUIWhenHidden() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
            /* Update this UI and any associated internal frame */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
            setUI((DesktopIconUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
            Dimension r = getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
            setSize(r.width, r.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
            invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
            Component[] children = getComponents();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
            if (children != null) {
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 715
diff changeset
  2259
                for (Component child : children) {
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 715
diff changeset
  2260
                    SwingUtilities.updateComponentTreeUI(child);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
         * Returns the name of the look-and-feel
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
         * class that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
         * @return the string "DesktopIconUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
         * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
         * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
        public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
            return "DesktopIconUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
        ////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
        // Serialization support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2278
        ////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2279
        private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2280
            s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2281
            if (getUIClassID().equals("DesktopIconUI")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2282
                byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2283
                JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2284
                if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
                    ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2286
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2287
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2290
       /////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
       // Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
       ////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
         * Gets the AccessibleContext associated with this JDesktopIcon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
         * For desktop icons, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
         * AccessibleJDesktopIcon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
         * A new AccessibleJDesktopIcon instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
         * @return an AccessibleJDesktopIcon that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2301
         *         AccessibleContext of this JDesktopIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
        public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2304
            if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2305
                accessibleContext = new AccessibleJDesktopIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2307
            return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2310
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
         * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
         * <code>JInternalFrame.JDesktopIcon</code> class.  It provides an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
         * implementation of the Java Accessibility API appropriate to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2314
         * desktop icon user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
         * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
         * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
         * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
         * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2319
         * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2320
         * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2321
         * of all JavaBeans<sup><font size="-2">TM</font></sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2322
         * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2323
         * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2324
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2325
        protected class AccessibleJDesktopIcon extends AccessibleJComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2326
            implements AccessibleValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2327
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2328
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2329
             * Gets the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2330
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2331
             * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2332
             * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2333
             * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2334
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2335
            public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2336
                return AccessibleRole.DESKTOP_ICON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2337
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2338
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2339
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2340
             * Gets the AccessibleValue associated with this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2341
             * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2342
             * returns this object, which is responsible for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2343
             * <code>AccessibleValue</code> interface on behalf of itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2344
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2345
             * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2346
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2347
            public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2348
                return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2349
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2351
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2352
            // AccessibleValue methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2353
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2355
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2356
             * Gets the value of this object as a <code>Number</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2357
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2358
             * @return value of the object -- can be <code>null</code> if this object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2359
             * have a value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2360
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2361
            public Number getCurrentAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2362
                AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2363
                AccessibleValue v = a.getAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2364
                if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2365
                    return v.getCurrentAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2366
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2372
             * Sets the value of this object as a <code>Number</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
             * @return <code>true</code> if the value was set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2375
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
            public boolean setCurrentAccessibleValue(Number n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
                // TIGER - 4422535
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
                if (n == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
                AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
                AccessibleValue v = a.getAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
                if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
                    return v.setCurrentAccessibleValue(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2387
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2388
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2389
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2390
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2391
             * Gets the minimum value of this object as a <code>Number</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2393
             * @return minimum value of the object; <code>null</code> if this object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2394
             * have a minimum value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2395
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2396
            public Number getMinimumAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2397
                AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2398
                if (a instanceof AccessibleValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2399
                    return ((AccessibleValue)a).getMinimumAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2400
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2401
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2402
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2403
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2404
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2405
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2406
             * Gets the maximum value of this object as a <code>Number</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2407
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2408
             * @return maximum value of the object; <code>null</code> if this object does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2409
             * have a maximum value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2410
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2411
            public Number getMaximumAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2412
                AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2413
                if (a instanceof AccessibleValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2414
                    return ((AccessibleValue)a).getMaximumAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2415
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2416
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2417
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2418
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2419
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2420
        } // AccessibleJDesktopIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2422
}