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