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