jdk/src/share/classes/javax/swing/JWindow.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 21255 0afb44cd0215
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     2
 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
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: 1639
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: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * A <code>JWindow</code> is a container that can be displayed anywhere on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * user's desktop. It does not have the title bar, window-management buttons,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * or other trimmings associated with a <code>JFrame</code>, but it is still a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * "first-class citizen" of the user's desktop, and can exist anywhere
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * on it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * The <code>JWindow</code> component contains a <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * as its only child.  The <code>contentPane</code> should be the parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * of any children of the <code>JWindow</code>.
21255
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    46
 * As a convenience, the {@code add}, {@code remove}, and {@code setLayout}
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    47
 * methods of this class are overridden, so that they delegate calls
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    48
 * to the corresponding methods of the {@code ContentPane}.
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    49
 * For example, you can add a child component to a window as follows:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *       window.add(child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * And the child will be added to the contentPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * The <code>contentPane</code> will always be non-<code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Attempting to set it to <code>null</code> will cause the <code>JWindow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * to throw an exception. The default <code>contentPane</code> will have a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <code>BorderLayout</code> manager set on it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Refer to {@link javax.swing.RootPaneContainer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * for details on adding, removing and setting the <code>LayoutManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * of a <code>JWindow</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * Please see the {@link JRootPane} documentation for a complete description of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * the <code>contentPane</code>, <code>glassPane</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <code>layeredPane</code> components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * In a multi-screen environment, you can create a <code>JWindow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * on a different screen device.  See {@link java.awt.Window} for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * 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
    80
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *      attribute: isContainer true
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *      attribute: containerDelegate getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *    description: A toplevel window which has no system border or controls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
    93
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
public class JWindow extends Window implements Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                                               RootPaneContainer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                               TransferHandler.HasGetTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * The <code>JRootPane</code> instance that manages the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * and optional <code>menuBar</code> for this frame, as well as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * <code>glassPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @see #getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @see #setRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    protected JRootPane rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * If true then calls to <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * will be forwarded to the <code>contentPane</code>. This is initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * false, but is set to true when the <code>JWindow</code> is constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected boolean rootPaneCheckingEnabled = false;
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>TransferHandler</code> for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private TransferHandler transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Creates a window with no specified owner. This window will not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * focusable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @throws HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *         <code>GraphicsEnvironment.isHeadless()</code> returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @see #isFocusableWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public JWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this((Frame)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Creates a window with the specified <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * of a screen device. This window will not be focusable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param gc the <code>GraphicsConfiguration</code> that is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *          to construct the new window with; if gc is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *          the system default <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *          is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @throws HeadlessException If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *         <code>GraphicsEnvironment.isHeadless()</code> returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @throws IllegalArgumentException if <code>gc</code> is not from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *         a screen device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @see #isFocusableWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @since  1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public JWindow(GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        this(null, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        super.setFocusableWindowState(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Creates a window with the specified owner frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * If <code>owner</code> is <code>null</code>, the shared owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * will be used and this window will not be focusable. Also,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * this window will not be focusable unless its owner is showing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param owner the frame from which the window is displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @throws HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *            returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @see #isFocusableWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public JWindow(Frame owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        if (owner == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            WindowListener ownerShutdownListener =
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   190
                    SwingUtilities.getSharedOwnerFrameShutdownListener();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            addWindowListener(ownerShutdownListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        windowInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * Creates a window with the specified owner window. This window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * will not be focusable unless its owner is showing on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * If <code>owner</code> is <code>null</code>, the shared owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * will be used and this window will not be focusable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param owner the window from which the window is displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @throws HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *         <code>GraphicsEnvironment.isHeadless()</code> returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @see #isFocusableWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public JWindow(Window owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        super(owner == null ? (Window)SwingUtilities.getSharedOwnerFrame() :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
              owner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (owner == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            WindowListener ownerShutdownListener =
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   217
                    SwingUtilities.getSharedOwnerFrameShutdownListener();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            addWindowListener(ownerShutdownListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        windowInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Creates a window with the specified owner window and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <code>GraphicsConfiguration</code> of a screen device. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * <code>owner</code> is <code>null</code>, the shared owner will be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * and this window will not be focusable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @param owner the window from which the window is displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @param gc the <code>GraphicsConfiguration</code> that is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *          to construct the new window with; if gc is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *          the system default <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *          is assumed, unless <code>owner</code> is also null, in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *          case the <code>GraphicsConfiguration</code> from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *          shared owner frame will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @throws HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *         <code>GraphicsEnvironment.isHeadless()</code> returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @throws IllegalArgumentException if <code>gc</code> is not from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *         a screen device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @see #isFocusableWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @since  1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public JWindow(Window owner, GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        super(owner == null ? (Window)SwingUtilities.getSharedOwnerFrame() :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
              owner, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (owner == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            WindowListener ownerShutdownListener =
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   255
                    SwingUtilities.getSharedOwnerFrameShutdownListener();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            addWindowListener(ownerShutdownListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        windowInit();
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
     * Called by the constructors to init the <code>JWindow</code> properly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    protected void windowInit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        setLocale( JComponent.getDefaultLocale() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        setRootPane(createRootPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        setRootPaneCheckingEnabled(true);
12661
6cf8b7116579 7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents: 11268
diff changeset
   268
        sun.awt.SunToolkit.checkAndSetPolicy(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * Called by the constructor methods to create the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <code>rootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    protected JRootPane createRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        JRootPane rp = new JRootPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        // NOTE: this uses setOpaque vs LookAndFeel.installProperty as there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        // is NO reason for the RootPane not to be opaque. For painting to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // work the contentPane must be opaque, therefor the RootPane can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // also be opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        rp.setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        return rp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * Returns whether calls to <code>add</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @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
   290
     *         are forwarded; false otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    protected boolean isRootPaneCheckingEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        return rootPaneCheckingEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Sets the {@code transferHandler} property, which is a mechanism to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * support transfer of data into this component. Use {@code null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * if the component does not support data transfer operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * If the system property {@code suppressSwingDropSupport} is {@code false}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * (the default) and the current drop target on this component is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * {@code null} or not a user-set drop target, this method will change the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * drop target as follows: If {@code newHandler} is {@code null} it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * clear the drop target. If not {@code null} it will install a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * {@code DropTarget}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * Note: When used with {@code JWindow}, {@code TransferHandler} only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * provides data import capability, as the data export related methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * are currently typed to {@code JComponent}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Please see
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 12661
diff changeset
   318
     * <a href="http://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * How to Use Drag and Drop and Data Transfer</a>, a section in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <em>The Java Tutorial</em>, for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @param newHandler the new {@code TransferHandler}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @see TransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @see #getTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see java.awt.Component#setDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *  description: Mechanism for transfer of data into the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    public void setTransferHandler(TransferHandler newHandler) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        TransferHandler oldHandler = transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        transferHandler = newHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        firePropertyChange("transferHandler", oldHandler, newHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * Gets the <code>transferHandler</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @return the value of the <code>transferHandler</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @see TransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @see #setTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public TransferHandler getTransferHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        return transferHandler;
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
     * Calls <code>paint(g)</code>.  This method was overridden to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * prevent an unnecessary call to clear the background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @param g  the <code>Graphics</code> context in which to paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    public void update(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Sets whether calls to <code>add</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @param enabled  true if <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *        are forwarded, false if they should operate directly on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *        <code>JWindow</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *      hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * description: Whether the add and setLayout methods are forwarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    protected void setRootPaneCheckingEnabled(boolean enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        rootPaneCheckingEnabled = enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Adds the specified child <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * This method is overridden to conditionally forward calls to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * By default, children are added to the <code>contentPane</code> instead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * of the frame, refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @param comp the component to be enhanced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @param constraints the constraints to be respected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @param index the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @exception IllegalArgumentException if <code>index</code> is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @exception IllegalArgumentException if adding the container's parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *                  to itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @exception IllegalArgumentException if adding a window to a container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    protected void addImpl(Component comp, Object constraints, int index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            getContentPane().add(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            super.addImpl(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Removes the specified component from the container. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <code>comp</code> is not the <code>rootPane</code>, this will forward
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * the call to the <code>contentPane</code>. This will do nothing if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * <code>comp</code> is not a child of the <code>JWindow</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @param comp the component to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @throws NullPointerException if <code>comp</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @see #add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    public void remove(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        if (comp == rootPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            super.remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            getContentPane().remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * Sets the <code>LayoutManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * Overridden to conditionally forward the call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * Refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @param manager the <code>LayoutManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public void setLayout(LayoutManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            getContentPane().setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            super.setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * Returns the <code>rootPane</code> object for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @return the <code>rootPane</code> property for this window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @see #setRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @see RootPaneContainer#getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    public JRootPane getRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        return rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * Sets the new <code>rootPane</code> object for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @param root the new <code>rootPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * @see #getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *        hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *   description: the RootPane object for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    protected void setRootPane(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            remove(rootPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        rootPane = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            boolean checkingEnabled = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                add(rootPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                setRootPaneCheckingEnabled(checkingEnabled);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Returns the <code>Container</code> which is the <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @return the <code>contentPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @see #setContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @see RootPaneContainer#getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    public Container getContentPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        return getRootPane().getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * Sets the <code>contentPane</code> property for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @param contentPane the new <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @exception IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *            exception) if the content pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @see #getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see RootPaneContainer#setContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *     description: The client area of the window where child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *                  components are normally inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    public void setContentPane(Container contentPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        getRootPane().setContentPane(contentPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Returns the <code>layeredPane</code> object for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @return the <code>layeredPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @see #setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @see RootPaneContainer#getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    public JLayeredPane getLayeredPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        return getRootPane().getLayeredPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * Sets the <code>layeredPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * @param layeredPane the new <code>layeredPane</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * @exception IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     *            exception) if the content pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * @see #getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * @see RootPaneContainer#setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     *     description: The pane which holds the various window layers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    public void setLayeredPane(JLayeredPane layeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        getRootPane().setLayeredPane(layeredPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Returns the <code>glassPane Component</code> for this window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * @return the <code>glassPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * @see #setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * @see RootPaneContainer#getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    public Component getGlassPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        return getRootPane().getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * Sets the <code>glassPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @param glassPane the <code>glassPane</code> object for this window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * @see #getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @see RootPaneContainer#setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *     description: A transparent pane used for menu rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    public void setGlassPane(Component glassPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        getRootPane().setGlassPane(glassPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    public Graphics getGraphics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        JComponent.getGraphicsInvoked(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        return super.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * Repaints the specified rectangle of this component within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <code>time</code> milliseconds.  Refer to <code>RepaintManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * for details on how the repaint is handled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @param     time   maximum time in milliseconds before update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * @param     x    the <i>x</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @param     y    the <i>y</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @param     width    the width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @param     height   the height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @see       RepaintManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @since     1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    public void repaint(long time, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            RepaintManager.currentManager(this).addDirtyRegion(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                              this, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            super.repaint(time, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * Returns a string representation of this <code>JWindow</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @return  a string representation of this <code>JWindow</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                                                "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
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
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    /** The accessible context property. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    protected AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * Gets the AccessibleContext associated with this JWindow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * For JWindows, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * AccessibleJWindow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * A new AccessibleJWindow instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * @return an AccessibleJWindow that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     *         AccessibleContext of this JWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            accessibleContext = new AccessibleJWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * <code>JWindow</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * Java Accessibility API appropriate to window user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
   668
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    protected class AccessibleJWindow extends AccessibleAWTWindow {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        // everything is in the new parent, AccessibleAWTWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
}