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