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