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