jdk/src/share/classes/javax/swing/JFrame.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 21255 0afb44cd0215
child 21982 fd6e5fe509df
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2006, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * An extended version of <code>java.awt.Frame</code> that adds support for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * the JFC/Swing component architecture.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * You can find task-oriented documentation about using <code>JFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * in <em>The Java Tutorial</em>, in the section
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <a
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 15976
diff changeset
    43
 href="http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html">How to Make Frames</a>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * The <code>JFrame</code> class is slightly incompatible with <code>Frame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Like all other JFC/Swing top-level containers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * a <code>JFrame</code> contains a <code>JRootPane</code> as its only child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * The <b>content pane</b> provided by the root pane should,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * as a rule, contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * all the non-menu components displayed by the <code>JFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * This is different from the AWT <code>Frame</code> case.
21255
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    53
 * As a convenience, the {@code add}, {@code remove}, and {@code setLayout}
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    54
 * methods of this class are overridden, so that they delegate calls
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    55
 * to the corresponding methods of the {@code ContentPane}.
0afb44cd0215 7165112: Incomprehensible garbage in doc for RootPaneContainer
malenkov
parents: 20458
diff changeset
    56
 * For example, you can add a child component to a frame as follows:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *       frame.add(child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * And the child will be added to the contentPane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * The content pane will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * always be non-null. Attempting to set it to null will cause the JFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * to throw an exception. The default content pane will have a BorderLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * manager set on it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * Refer to {@link javax.swing.RootPaneContainer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * for details on adding, removing and setting the <code>LayoutManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * of a <code>JFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Unlike a <code>Frame</code>, a <code>JFrame</code> has some notion of how to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * respond when the user attempts to close the window. The default behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * is to simply hide the JFrame when the user closes the window. To change the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * default behavior, you invoke the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * {@link #setDefaultCloseOperation}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * To make the <code>JFrame</code> behave the same as a <code>Frame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * instance, use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <code>setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * For more information on content panes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * and other features that root panes provide,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * see <a
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 15976
diff changeset
    81
 href="http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html">Using Top-Level Containers</a> in <em>The Java Tutorial</em>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * In a multi-screen environment, you can create a <code>JFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * on a different screen device.  See {@link java.awt.Frame} for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * 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
    97
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @see java.awt.event.WindowListener#windowClosing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *      attribute: isContainer true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *      attribute: containerDelegate getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *    description: A toplevel window which can be minimized to an icon.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * @author Jeff Dinkins
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
public class JFrame  extends Frame implements WindowConstants,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                              Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                                              RootPaneContainer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                              TransferHandler.HasGetTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * The exit application default window close operation. If a window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * has this set as the close operation and is closed in an applet,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * a <code>SecurityException</code> may be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * It is recommended you only use this in an application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public static final int EXIT_ON_CLOSE = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Key into the AppContext, used to check if should provide decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    private static final Object defaultLookAndFeelDecoratedKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            new StringBuffer("JFrame.defaultLookAndFeelDecorated");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    private int defaultCloseOperation = HIDE_ON_CLOSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * The <code>TransferHandler</code> for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private TransferHandler transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * The <code>JRootPane</code> instance that manages the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * and optional <code>menuBar</code> for this frame, as well as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * <code>glassPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @see RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    protected JRootPane rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * If true then calls to <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * will be forwarded to the <code>contentPane</code>. This is initially
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * false, but is set to true when the <code>JFrame</code> is constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    protected boolean rootPaneCheckingEnabled = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Constructs a new frame that is initially invisible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public JFrame() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        frameInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Creates a <code>Frame</code> in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <code>GraphicsConfiguration</code> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * a screen device and a blank title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @param gc the <code>GraphicsConfiguration</code> that is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *          to construct the new <code>Frame</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *          if <code>gc</code> is <code>null</code>, the system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *          default <code>GraphicsConfiguration</code> is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @exception IllegalArgumentException if <code>gc</code> is not from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *          a screen device.  This exception is always thrown when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *      GraphicsEnvironment.isHeadless() returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @since     1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public JFrame(GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        super(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        frameInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Creates a new, initially invisible <code>Frame</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * specified title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @param title the title for the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public JFrame(String title) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        super(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        frameInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * Creates a <code>JFrame</code> with the specified title and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * specified <code>GraphicsConfiguration</code> of a screen device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * This constructor sets the component's locale property to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * returned by <code>JComponent.getDefaultLocale</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @param title the title to be displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *          frame's border. A <code>null</code> value is treated as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *          an empty string, "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @param gc the <code>GraphicsConfiguration</code> that is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *          to construct the new <code>JFrame</code> with;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *          if <code>gc</code> is <code>null</code>, the system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *          default <code>GraphicsConfiguration</code> is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @exception IllegalArgumentException if <code>gc</code> is not from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *          a screen device.  This exception is always thrown when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *      GraphicsEnvironment.isHeadless() returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @since     1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public JFrame(String title, GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        super(title, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        frameInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /** Called by the constructors to init the <code>JFrame</code> properly. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    protected void frameInit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        setLocale( JComponent.getDefaultLocale() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        setRootPane(createRootPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        setBackground(UIManager.getColor("control"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        setRootPaneCheckingEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        if (JFrame.isDefaultLookAndFeelDecorated()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            boolean supportsWindowDecorations =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            UIManager.getLookAndFeel().getSupportsWindowDecorations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            if (supportsWindowDecorations) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                setUndecorated(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
12661
6cf8b7116579 7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents: 5506
diff changeset
   270
        sun.awt.SunToolkit.checkAndSetPolicy(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Called by the constructor methods to create the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * <code>rootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    protected JRootPane createRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        JRootPane rp = new JRootPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // NOTE: this uses setOpaque vs LookAndFeel.installProperty as there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // is NO reason for the RootPane not to be opaque. For painting to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        // work the contentPane must be opaque, therefor the RootPane can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        // also be opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        rp.setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return rp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Processes window events occurring on this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * Hides the window or disposes of it, as specified by the setting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * of the <code>defaultCloseOperation</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @param  e  the window event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @see    #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @see    java.awt.Window#processWindowEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    protected void processWindowEvent(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        super.processWindowEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            switch(defaultCloseOperation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
              case HIDE_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                 setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
              case DISPOSE_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                 dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
              case DO_NOTHING_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                 default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
              case EXIT_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                  // This needs to match the checkExit call in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                  // setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                System.exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
//    public void setMenuBar(MenuBar menu) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
//        throw new IllegalComponentStateException("Please use setJMenuBar() with JFrame.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
//    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * Sets the operation that will happen by default when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * the user initiates a "close" on this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * You must specify one of the following choices:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * <li><code>DO_NOTHING_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * (defined in <code>WindowConstants</code>):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Don't do anything; require the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * program to handle the operation in the <code>windowClosing</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * method of a registered <code>WindowListener</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * <li><code>HIDE_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * (defined in <code>WindowConstants</code>):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Automatically hide the frame after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * invoking any registered <code>WindowListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <li><code>DISPOSE_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * (defined in <code>WindowConstants</code>):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * Automatically hide and dispose the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * frame after invoking any registered <code>WindowListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * <li><code>EXIT_ON_CLOSE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * (defined in <code>JFrame</code>):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * Exit the application using the <code>System</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * <code>exit</code> method.  Use this only in applications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * The value is set to <code>HIDE_ON_CLOSE</code> by default. Changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * to the value of this property cause the firing of a property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * change event, with property name "defaultCloseOperation".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * <b>Note</b>: When the last displayable window within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Java virtual machine (VM) is disposed of, the VM may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * terminate.  See <a href="../../java/awt/doc-files/AWTThreadIssues.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * AWT Threading Issues</a> for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @param operation the operation which should be performed when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *        user closes the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @exception IllegalArgumentException if defaultCloseOperation value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *             isn't one of the above valid values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @see #addWindowListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @see #getDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @see WindowConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @throws  SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *        if <code>EXIT_ON_CLOSE</code> has been specified and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *        <code>SecurityManager</code> will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *        not allow the caller to invoke <code>System.exit</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @see        java.lang.Runtime#exit(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     *   preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     *       bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *        enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *              HIDE_ON_CLOSE       WindowConstants.HIDE_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *              DISPOSE_ON_CLOSE    WindowConstants.DISPOSE_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *              EXIT_ON_CLOSE       WindowConstants.EXIT_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * description: The frame's default close operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    public void setDefaultCloseOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (operation != DO_NOTHING_ON_CLOSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            operation != HIDE_ON_CLOSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            operation != DISPOSE_ON_CLOSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            operation != EXIT_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        }
15976
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   391
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   392
        if (operation == EXIT_ON_CLOSE) {
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   393
            SecurityManager security = System.getSecurityManager();
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   394
            if (security != null) {
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   395
                security.checkExit(0);
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   396
            }
f9578ba3a2c1 7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
alexsch
parents: 12661
diff changeset
   397
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        if (this.defaultCloseOperation != operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            int oldValue = this.defaultCloseOperation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            this.defaultCloseOperation = operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            firePropertyChange("defaultCloseOperation", oldValue, operation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    * Returns the operation that occurs when the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    * initiates a "close" on this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    * @return an integer indicating the window-close operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    public int getDefaultCloseOperation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        return defaultCloseOperation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * Sets the {@code transferHandler} property, which is a mechanism to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * support transfer of data into this component. Use {@code null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * if the component does not support data transfer operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * If the system property {@code suppressSwingDropSupport} is {@code false}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * (the default) and the current drop target on this component is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * {@code null} or not a user-set drop target, this method will change the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * drop target as follows: If {@code newHandler} is {@code null} it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * clear the drop target. If not {@code null} it will install a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * {@code DropTarget}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * Note: When used with {@code JFrame}, {@code TransferHandler} only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * provides data import capability, as the data export related methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * are currently typed to {@code JComponent}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * Please see
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 15976
diff changeset
   434
     * <a href="http://docs.oracle.com/javase/tutorial/uiswing/dnd/index.html">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * How to Use Drag and Drop and Data Transfer</a>, a section in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <em>The Java Tutorial</em>, for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @param newHandler the new {@code TransferHandler}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * @see TransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * @see #getTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @see java.awt.Component#setDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *  description: Mechanism for transfer of data into the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public void setTransferHandler(TransferHandler newHandler) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        TransferHandler oldHandler = transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        transferHandler = newHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        firePropertyChange("transferHandler", oldHandler, newHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * Gets the <code>transferHandler</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @return the value of the <code>transferHandler</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @see TransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @see #setTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public TransferHandler getTransferHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        return transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * Just calls <code>paint(g)</code>.  This method was overridden to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * prevent an unnecessary call to clear the background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @param g the Graphics context in which to paint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    public void update(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    * Sets the menubar for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    * @param menubar the menubar being placed in the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    * @see #getJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    *      hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    * description: The menubar for accessing pulldown menus from this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    public void setJMenuBar(JMenuBar menubar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        getRootPane().setMenuBar(menubar);
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
    * Returns the menubar set on this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    * @return the menubar for this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    * @see #setJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    public JMenuBar getJMenuBar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        return getRootPane().getMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * Returns whether calls to <code>add</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @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
   509
     *         are forwarded; false otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    protected boolean isRootPaneCheckingEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        return rootPaneCheckingEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * Sets whether calls to <code>add</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * @param enabled  true if <code>add</code> and <code>setLayout</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     *        are forwarded, false if they should operate directly on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *        <code>JFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     *      hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * description: Whether the add and setLayout methods are forwarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    protected void setRootPaneCheckingEnabled(boolean enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        rootPaneCheckingEnabled = enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * Adds the specified child <code>Component</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * This method is overridden to conditionally forward calls to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * By default, children are added to the <code>contentPane</code> instead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * of the frame, refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * @param comp the component to be enhanced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * @param constraints the constraints to be respected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @param index the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @exception IllegalArgumentException if <code>index</code> is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @exception IllegalArgumentException if adding the container's parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *                  to itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @exception IllegalArgumentException if adding a window to a container
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    protected void addImpl(Component comp, Object constraints, int index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            getContentPane().add(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            super.addImpl(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * Removes the specified component from the container. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * <code>comp</code> is not the <code>rootPane</code>, this will forward
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * the call to the <code>contentPane</code>. This will do nothing if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * <code>comp</code> is not a child of the <code>JFrame</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @param comp the component to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * @throws NullPointerException if <code>comp</code> is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @see #add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    public void remove(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        if (comp == rootPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            super.remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            getContentPane().remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * Sets the <code>LayoutManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * Overridden to conditionally forward the call to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * Refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @param manager the <code>LayoutManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    public void setLayout(LayoutManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            getContentPane().setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            super.setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * Returns the <code>rootPane</code> object for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @return the <code>rootPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * @see #setRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @see RootPaneContainer#getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    public JRootPane getRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        return rootPane;
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * Sets the <code>rootPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * @param root the <code>rootPane</code> object for this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * @see #getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     *   hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * description: the RootPane object for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    protected void setRootPane(JRootPane root)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            remove(rootPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        rootPane = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            boolean checkingEnabled = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                add(rootPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                setRootPaneCheckingEnabled(checkingEnabled);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    public void setIconImage(Image image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        super.setIconImage(image);
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
     * Returns the <code>contentPane</code> object for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * @return the <code>contentPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * @see #setContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * @see RootPaneContainer#getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    public Container getContentPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        return getRootPane().getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Sets the <code>contentPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * Swing's painting architecture requires an opaque <code>JComponent</code>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21255
diff changeset
   677
     * in the containment hierarchy. This is typically provided by the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * content pane. If you replace the content pane it is recommended you
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * replace it with an opaque <code>JComponent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * @param contentPane the <code>contentPane</code> object for this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @exception java.awt.IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     *            exception) if the content pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @see #getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @see RootPaneContainer#setContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     *     description: The client area of the frame where child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     *                  components are normally inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    public void setContentPane(Container contentPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        getRootPane().setContentPane(contentPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * Returns the <code>layeredPane</code> object for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @return the <code>layeredPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @see #setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * @see RootPaneContainer#getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    public JLayeredPane getLayeredPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        return getRootPane().getLayeredPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * Sets the <code>layeredPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @param layeredPane the <code>layeredPane</code> object for this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * @exception java.awt.IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *            exception) if the layered pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * @see #getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * @see RootPaneContainer#setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     *     description: The pane that holds the various frame layers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    public void setLayeredPane(JLayeredPane layeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        getRootPane().setLayeredPane(layeredPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * Returns the <code>glassPane</code> object for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * @return the <code>glassPane</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * @see #setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * @see RootPaneContainer#getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    public Component getGlassPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        return getRootPane().getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * Sets the <code>glassPane</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @param glassPane the <code>glassPane</code> object for this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * @see #getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * @see RootPaneContainer#setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     *     description: A transparent pane used for menu rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    public void setGlassPane(Component glassPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        getRootPane().setGlassPane(glassPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    public Graphics getGraphics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        JComponent.getGraphicsInvoked(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        return super.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Repaints the specified rectangle of this component within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * <code>time</code> milliseconds.  Refer to <code>RepaintManager</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * for details on how the repaint is handled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * @param     time   maximum time in milliseconds before update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * @param     x    the <i>x</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * @param     y    the <i>y</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @param     width    the width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * @param     height   the height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @see       RepaintManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @since     1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    public void repaint(long time, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            RepaintManager.currentManager(this).addDirtyRegion(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                              this, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            super.repaint(time, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * Provides a hint as to whether or not newly created <code>JFrame</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * should have their Window decorations (such as borders, widgets to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * close the window, title...) provided by the current look
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * and feel. If <code>defaultLookAndFeelDecorated</code> is true,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * the current <code>LookAndFeel</code> supports providing window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * decorations, and the current window manager supports undecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * windows, then newly created <code>JFrame</code>s will have their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * Window decorations provided by the current <code>LookAndFeel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * Otherwise, newly created <code>JFrame</code>s will have their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * Window decorations provided by the current window manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * You can get the same effect on a single JFrame by doing the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     *    JFrame frame = new JFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     *    frame.setUndecorated(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *    frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * @param defaultLookAndFeelDecorated A hint as to whether or not current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     *        look and feel should provide window decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @see javax.swing.LookAndFeel#getSupportsWindowDecorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        if (defaultLookAndFeelDecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * Returns true if newly created <code>JFrame</code>s should have their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * Window decorations provided by the current look and feel. This is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * a hint, as certain look and feels may not support this feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * @return true if look and feel should provide Window decorations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    public static boolean isDefaultLookAndFeelDecorated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        Boolean defaultLookAndFeelDecorated =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
            (Boolean) SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if (defaultLookAndFeelDecorated == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            defaultLookAndFeelDecorated = Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        return defaultLookAndFeelDecorated.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * Returns a string representation of this <code>JFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * @return  a string representation of this <code>JFrame</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        String defaultCloseOperationString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        if (defaultCloseOperation == HIDE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            defaultCloseOperationString = "HIDE_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            defaultCloseOperationString = "DISPOSE_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        } else if (defaultCloseOperation == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            defaultCloseOperationString = "EXIT_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        } else defaultCloseOperationString = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        String rootPaneString = (rootPane != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                                 rootPane.toString() : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                                                "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        ",defaultCloseOperation=" + defaultCloseOperationString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        ",rootPane=" + rootPaneString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    /** The accessible context property. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    protected AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * Gets the AccessibleContext associated with this JFrame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * For JFrames, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * AccessibleJFrame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * A new AccessibleJFrame instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * @return an AccessibleJFrame that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     *         AccessibleContext of this JFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            accessibleContext = new AccessibleJFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * <code>JFrame</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * Java Accessibility API appropriate to frame user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    protected class AccessibleJFrame extends AccessibleAWTFrame {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        // AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
         * Get the accessible name of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
         * @return the localized name of the object -- can be null if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
         * object does not have a name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            if (accessibleName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                return accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                if (getTitle() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                    return super.getAccessibleName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                    return getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            if (isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                states.add(AccessibleState.RESIZABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            if (getFocusOwner() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            // FIXME:  [[[WDW - should also return ICONIFIED and ICONIFIABLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            // if we can ever figure these out]]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    } // inner class AccessibleJFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
}