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