jdk/src/share/classes/javax/swing/JRootPane.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 20458 f2423fb3fd19
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
     2
 * Copyright (c) 1997, 2007, 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: 4261
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: 4261
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: 4261
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4261
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.applet.Applet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.RootPaneUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.border.*;
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 2
diff changeset
    37
import sun.awt.AWTAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.security.action.GetBooleanAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * A lightweight container used behind the scenes by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <code>JFrame</code>, <code>JDialog</code>, <code>JWindow</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <code>JApplet</code>, and <code>JInternalFrame</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * For task-oriented information on functionality provided by root panes
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 20157
diff changeset
    46
 * see <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html">How to Use Root Panes</a>,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * a section in <em>The Java Tutorial</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The following image shows the relationships between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the classes that use root panes.
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20455
diff changeset
    52
 * <p style="text-align:center"><img src="doc-files/JRootPane-1.gif"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * alt="The following text describes this graphic."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * HEIGHT=484 WIDTH=629></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * The &quot;heavyweight&quot; components (those that delegate to a peer, or native
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * component on the host system) are shown with a darker, heavier box. The four
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * heavyweight JFC/Swing containers (<code>JFrame</code>, <code>JDialog</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <code>JWindow</code>, and <code>JApplet</code>) are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * shown in relation to the AWT classes they extend.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * These four components are the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * only heavyweight containers in the Swing library. The lightweight container
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <code>JInternalFrame</code> is also shown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * All five of these JFC/Swing containers implement the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <code>RootPaneContainer</code> interface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * and they all delegate their operations to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <code>JRootPane</code> (shown with a little "handle" on top).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <b>Note:</b> The <code>JComponent</code> method <code>getRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * can be used to obtain the <code>JRootPane</code> that contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * a given component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * </blockquote>
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20455
diff changeset
    72
 * <table style="float:right" border="0" summary="layout">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <td align="center">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <img src="doc-files/JRootPane-2.gif"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * alt="The following text describes this graphic." HEIGHT=386 WIDTH=349>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * The diagram at right shows the structure of a <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * A <code>JRootpane</code> is made up of a <code>glassPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * an optional <code>menuBar</code>, and a <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * (The <code>JLayeredPane</code> manages the <code>menuBar</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * and the <code>contentPane</code>.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * The <code>glassPane</code> sits over the top of everything,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * where it is in a position to intercept mouse movements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * Since the <code>glassPane</code> (like the <code>contentPane</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * can be an arbitrary component, it is also possible to set up the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <code>glassPane</code> for drawing. Lines and images on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <code>glassPane</code> can then range
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * over the frames underneath without being limited by their boundaries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Although the <code>menuBar</code> component is optional,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * the <code>layeredPane</code>, <code>contentPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * and <code>glassPane</code> always exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * Attempting to set them to <code>null</code> generates an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * To add components to the <code>JRootPane</code> (other than the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * optional menu bar), you add the object to the <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * of the <code>JRootPane</code>, like this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *       rootPane.getContentPane().add(child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * The same principle holds true for setting layout managers, removing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * components, listing children, etc. All these methods are invoked on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * the <code>contentPane</code> instead of on the <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * <b>Note:</b> The default layout manager for the <code>contentPane</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *  a <code>BorderLayout</code> manager. However, the <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *  uses a custom <code>LayoutManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *  So, when you want to change the layout manager for the components you added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *  to a <code>JRootPane</code>, be sure to use code like this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *    rootPane.getContentPane().setLayout(new BoxLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * If a <code>JMenuBar</code> component is set on the <code>JRootPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * it is positioned along the upper edge of the frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * The <code>contentPane</code> is adjusted in location and size to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * fill the remaining area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * (The <code>JMenuBar</code> and the <code>contentPane</code> are added to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * <code>layeredPane</code> component at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * <code>JLayeredPane.FRAME_CONTENT_LAYER</code> layer.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * The <code>layeredPane</code> is the parent of all children in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * <code>JRootPane</code> -- both as the direct parent of the menu and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * the grandparent of all components added to the <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * It is an instance of <code>JLayeredPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * which provides the ability to add components at several layers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * This capability is very useful when working with menu popups,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * dialog boxes, and dragging -- situations in which you need to place
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * a component on top of all other components in the pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * The <code>glassPane</code> sits on top of all other components in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * That provides a convenient place to draw above all other components,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * and makes it possible to intercept mouse events,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * which is useful both for dragging and for drawing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * Developers can use <code>setVisible</code> on the <code>glassPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * to control when the <code>glassPane</code> displays over the other children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * By default the <code>glassPane</code> is not visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * The custom <code>LayoutManager</code> used by <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * ensures that:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * <OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * <LI>The <code>glassPane</code> fills the entire viewable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *     area of the <code>JRootPane</code> (bounds - insets).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * <LI>The <code>layeredPane</code> fills the entire viewable area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 *     <code>JRootPane</code>. (bounds - insets)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * <LI>The <code>menuBar</code> is positioned at the upper edge of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *     <code>layeredPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * <LI>The <code>contentPane</code> fills the entire viewable area,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *     minus the <code>menuBar</code>, if present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * </OL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * Any other views in the <code>JRootPane</code> view hierarchy are ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * If you replace the <code>LayoutManager</code> of the <code>JRootPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * you are responsible for managing all of these views.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * So ordinarily you will want to be sure that you
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * change the layout manager for the <code>contentPane</code> rather than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * for the <code>JRootPane</code> itself!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * The painting architecture of Swing requires an opaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * <code>JComponent</code>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20458
diff changeset
   164
 * to exist in the containment hierarchy above all other components. This is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * typically provided by way of the content pane. If you replace the content
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * pane, it is recommended that you make the content pane opaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * by way of <code>setOpaque(true)</code>. Additionally, if the content pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 * overrides <code>paintComponent</code>, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * will need to completely fill in the background in an opaque color in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 * <code>paintComponent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * 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
   182
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * @see JLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * @see JMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * @see JWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * @see JFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * @see JDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * @see JApplet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * @see JInternalFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * @see JComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 * @see BoxLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
 * @see <a href="http://java.sun.com/products/jfc/tsc/articles/mixing/">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 * Mixing Heavy and Light Components</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
/// PENDING(klobad) Who should be opaque in this component?
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
   202
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
public class JRootPane extends JComponent implements Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    private static final String uiClassID = "RootPaneUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Whether or not we should dump the stack when true double buffering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * is disabled. Default is false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    private static final boolean LOG_DISABLE_TRUE_DOUBLE_BUFFERING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Whether or not we should ignore requests to disable true double
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * buffering. Default is false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    private static final boolean IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * the <code>JRootPane</code> should not provide any sort of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Window decorations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public static final int NONE = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * a Frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public static final int FRAME = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * a Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public static final int PLAIN_DIALOG = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * a Dialog used to display an informational message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public static final int INFORMATION_DIALOG = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * a Dialog used to display an error message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public static final int ERROR_DIALOG = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * a Dialog used to display a <code>JColorChooser</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public static final int COLOR_CHOOSER_DIALOG = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * a Dialog used to display a <code>JFileChooser</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public static final int FILE_CHOOSER_DIALOG = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * a Dialog used to present a question to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    public static final int QUESTION_DIALOG = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * Constant used for the windowDecorationStyle property. Indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * the <code>JRootPane</code> should provide decorations appropriate for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * a Dialog used to display a warning message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    public static final int WARNING_DIALOG = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    private int windowDecorationStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    /** The menu bar. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    protected JMenuBar menuBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /** The content pane. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    protected Container contentPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    /** The layered pane that manages the menu bar and content pane. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    protected JLayeredPane layeredPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * The glass pane that overlays the menu bar and content pane,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *  so it can intercept mouse movements and such.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    protected Component glassPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * The button that gets activated when the pane has the focus and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * a UI-specific action like pressing the <b>Enter</b> key occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    protected JButton defaultButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * As of Java 2 platform v1.3 this unusable field is no longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * To override the default button you should replace the <code>Action</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * in the <code>JRootPane</code>'s <code>ActionMap</code>. Please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @deprecated As of Java 2 platform v1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *  @see #defaultButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    protected DefaultAction defaultPressAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * As of Java 2 platform v1.3 this unusable field is no longer used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * To override the default button you should replace the <code>Action</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * in the <code>JRootPane</code>'s <code>ActionMap</code>. Please refer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * the key bindings specification for further details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @deprecated As of Java 2 platform v1.3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *  @see #defaultButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    protected DefaultAction defaultReleaseAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * Whether or not true double buffering should be used.  This is typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * true, but may be set to false in special situations.  For example,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * heavy weight popups (backed by a window) set this to false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    boolean useTrueDoubleBuffering = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        LOG_DISABLE_TRUE_DOUBLE_BUFFERING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            AccessController.doPrivileged(new GetBooleanAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                                   "swing.logDoubleBufferingDisable"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            AccessController.doPrivileged(new GetBooleanAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                                   "swing.ignoreDoubleBufferingDisable"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Creates a <code>JRootPane</code>, setting up its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * <code>glassPane</code>, <code>layeredPane</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * and <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public JRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        setGlassPane(createGlassPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        setLayeredPane(createLayeredPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        setContentPane(createContentPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        setLayout(createRootLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        setDoubleBuffered(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public void setDoubleBuffered(boolean aFlag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (isDoubleBuffered() != aFlag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            super.setDoubleBuffered(aFlag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            RepaintManager.currentManager(this).doubleBufferingChanged(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Returns a constant identifying the type of Window decorations the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * <code>JRootPane</code> is providing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @return One of <code>NONE</code>, <code>FRAME</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *        <code>PLAIN_DIALOG</code>, <code>INFORMATION_DIALOG</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *        <code>ERROR_DIALOG</code>, <code>COLOR_CHOOSER_DIALOG</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *        <code>FILE_CHOOSER_DIALOG</code>, <code>QUESTION_DIALOG</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *        <code>WARNING_DIALOG</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @see #setWindowDecorationStyle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    public int getWindowDecorationStyle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        return windowDecorationStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Sets the type of Window decorations (such as borders, widgets for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * closing a Window, title ...) the <code>JRootPane</code> should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * provide. The default is to provide no Window decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * (<code>NONE</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * This is only a hint, and some look and feels may not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * This is a bound property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @param windowDecorationStyle Constant identifying Window decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *        to provide.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @see JDialog#setDefaultLookAndFeelDecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @see JFrame#setDefaultLookAndFeelDecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see LookAndFeel#getSupportsWindowDecorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @throws IllegalArgumentException if <code>style</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *        not one of: <code>NONE</code>, <code>FRAME</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *        <code>PLAIN_DIALOG</code>, <code>INFORMATION_DIALOG</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *        <code>ERROR_DIALOG</code>, <code>COLOR_CHOOSER_DIALOG</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *        <code>FILE_CHOOSER_DIALOG</code>, <code>QUESTION_DIALOG</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *        <code>WARNING_DIALOG</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *         enum: NONE                   JRootPane.NONE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     *               FRAME                  JRootPane.FRAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *               PLAIN_DIALOG           JRootPane.PLAIN_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *               INFORMATION_DIALOG     JRootPane.INFORMATION_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *               ERROR_DIALOG           JRootPane.ERROR_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *               COLOR_CHOOSER_DIALOG   JRootPane.COLOR_CHOOSER_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *               FILE_CHOOSER_DIALOG    JRootPane.FILE_CHOOSER_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *               QUESTION_DIALOG        JRootPane.QUESTION_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     *               WARNING_DIALOG         JRootPane.WARNING_DIALOG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *       expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *  description: Identifies the type of Window decorations to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public void setWindowDecorationStyle(int windowDecorationStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        if (windowDecorationStyle < 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                  windowDecorationStyle > WARNING_DIALOG) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            throw new IllegalArgumentException("Invalid decoration style");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        int oldWindowDecorationStyle = getWindowDecorationStyle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        this.windowDecorationStyle = windowDecorationStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        firePropertyChange("windowDecorationStyle",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                            oldWindowDecorationStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                            windowDecorationStyle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    /**
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   451
     * Returns the L&amp;F object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @return <code>LabelUI</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    public RootPaneUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        return (RootPaneUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   461
     * Sets the L&amp;F object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   463
     * @param ui  the <code>LabelUI</code> L&amp;F object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *      expert: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *  description: The UI object that implements the Component's LookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public void setUI(RootPaneUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * Resets the UI property to a value from the current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        setUI((RootPaneUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    /**
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   489
     * Returns a string that specifies the name of the L&amp;F class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * that renders this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @return the string "RootPaneUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
      * Called by the constructor methods to create the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
      * <code>layeredPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      * Bt default it creates a new <code>JLayeredPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
      * @return the default <code>layeredPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    protected JLayeredPane createLayeredPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        JLayeredPane p = new JLayeredPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        p.setName(this.getName()+".layeredPane");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * Called by the constructor methods to create the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * <code>contentPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * By default this method creates a new <code>JComponent</code> add sets a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * <code>BorderLayout</code> as its <code>LayoutManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @return the default <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    protected Container createContentPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        JComponent c = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        c.setName(this.getName()+".contentPane");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        c.setLayout(new BorderLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            /* This BorderLayout subclass maps a null constraint to CENTER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
             * Although the reference BorderLayout also does this, some VMs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
             * throw an IllegalArgumentException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            public void addLayoutComponent(Component comp, Object constraints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                if (constraints == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                    constraints = BorderLayout.CENTER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                super.addLayoutComponent(comp, constraints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
      * Called by the constructor methods to create the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
      * <code>glassPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
      * By default this method creates a new <code>JComponent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
      * with visibility set to false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
      * @return the default <code>glassPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    protected Component createGlassPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        JComponent c = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        c.setName(this.getName()+".glassPane");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        c.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        ((JPanel)c).setOpaque(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * Called by the constructor methods to create the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * <code>layoutManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @return the default <code>layoutManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    protected LayoutManager createRootLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        return new RootLayout();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * Adds or changes the menu bar used in the layered pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * @param menu the <code>JMenuBar</code> to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    public void setJMenuBar(JMenuBar menu) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        if(menuBar != null && menuBar.getParent() == layeredPane)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            layeredPane.remove(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        menuBar = menu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        if(menuBar != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            layeredPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Specifies the menu bar value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * @deprecated As of Swing version 1.0.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *  replaced by <code>setJMenuBar(JMenuBar menu)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * @param menu the <code>JMenuBar</code> to add.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    public void setMenuBar(JMenuBar menu){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        if(menuBar != null && menuBar.getParent() == layeredPane)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            layeredPane.remove(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        menuBar = menu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        if(menuBar != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            layeredPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
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
     * Returns the menu bar from the layered pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * @return the <code>JMenuBar</code> used in the pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    public JMenuBar getJMenuBar() { return menuBar; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * Returns the menu bar value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @deprecated As of Swing version 1.0.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *  replaced by <code>getJMenuBar()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @return the <code>JMenuBar</code> used in the pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    public JMenuBar getMenuBar() { return menuBar; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Sets the content pane -- the container that holds the components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * parented by the root pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * Swing's painting architecture requires an opaque <code>JComponent</code>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20458
diff changeset
   611
     * in the containment hierarchy. This is typically provided by the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * content pane. If you replace the content pane it is recommended you
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * replace it with an opaque <code>JComponent</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @param content the <code>Container</code> to use for component-contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * @exception java.awt.IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *            exception) if the content pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    public void setContentPane(Container content) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        if(content == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            throw new IllegalComponentStateException("contentPane cannot be set to null.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        if(contentPane != null && contentPane.getParent() == layeredPane)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            layeredPane.remove(contentPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        contentPane = content;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        layeredPane.add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Returns the content pane -- the container that holds the components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * parented by the root pane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @return the <code>Container</code> that holds the component-contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    public Container getContentPane() { return contentPane; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
// PENDING(klobad) Should this reparent the contentPane and MenuBar?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * Sets the layered pane for the root pane. The layered pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * typically holds a content pane and an optional <code>JMenuBar</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @param layered  the <code>JLayeredPane</code> to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * @exception java.awt.IllegalComponentStateException (a runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     *            exception) if the layered pane parameter is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public void setLayeredPane(JLayeredPane layered) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        if(layered == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            throw new IllegalComponentStateException("layeredPane cannot be set to null.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        if(layeredPane != null && layeredPane.getParent() == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            this.remove(layeredPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        layeredPane = layered;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        this.add(layeredPane, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * Gets the layered pane used by the root pane. The layered pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * typically holds a content pane and an optional <code>JMenuBar</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @return the <code>JLayeredPane</code> currently in use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    public JLayeredPane getLayeredPane() { return layeredPane; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * Sets a specified <code>Component</code> to be the glass pane for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * root pane.  The glass pane should normally be a lightweight,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * transparent component, because it will be made visible when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * ever the root pane needs to grab input events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * The new glass pane's visibility is changed to match that of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * the current glass pane.  An implication of this is that care
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * must be taken when you want to replace the glass pane and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * make it visible.  Either of the following will work:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     *   root.setGlassPane(newGlassPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     *   newGlassPane.setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * or:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *   root.getGlassPane().setVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     *   root.setGlassPane(newGlassPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @param glass the <code>Component</code> to use as the glass pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     *              for this <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @exception NullPointerException if the <code>glass</code> parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     *          <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    public void setGlassPane(Component glass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        if (glass == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            throw new NullPointerException("glassPane cannot be set to null.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
1978
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 2
diff changeset
   693
        AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass,
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 2
diff changeset
   694
                new Rectangle());
8b981ce05cd0 6797195: Forward-port enhancements for hw/lw mixing from 6u12 to 7
anthony
parents: 2
diff changeset
   695
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        boolean visible = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        if (glassPane != null && glassPane.getParent() == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            this.remove(glassPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            visible = glassPane.isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        glass.setVisible(visible);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        glassPane = glass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        this.add(glassPane, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * Returns the current glass pane for this <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @return the current glass pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * @see #setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    public Component getGlassPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        return glassPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * If a descendant of this <code>JRootPane</code> calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * <code>revalidate</code>, validate from here on down.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * Deferred requests to layout a component and its descendents again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * For example, calls to <code>revalidate</code>, are pushed upwards to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * either a <code>JRootPane</code> or a <code>JScrollPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * because both classes override <code>isValidateRoot</code> to return true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @see JComponent#isValidateRoot
4261
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 1978
diff changeset
   729
     * @see java.awt.Container#isValidateRoot
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @return true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     */
4261
126dc6fe0d7b 6852592: invalidate() must be smarter
anthony
parents: 1978
diff changeset
   732
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    public boolean isValidateRoot() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * The <code>glassPane</code> and <code>contentPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * have the same bounds, which means <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * does not tiles its children and this should return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * On the other hand, the <code>glassPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * is normally not visible, and so this can return true if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * <code>glassPane</code> isn't visible. Therefore, the
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20458
diff changeset
   744
     * return value here depends upon the visibility of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * <code>glassPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * @return true if this component's children don't overlap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    public boolean isOptimizedDrawingEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        return !glassPane.isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        enableEvents(AWTEvent.KEY_EVENT_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    public void removeNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        super.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * Sets the <code>defaultButton</code> property,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * which determines the current default button for this <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * The default button is the button which will be activated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * when a UI-defined activation event (typically the <b>Enter</b> key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * occurs in the root pane regardless of whether or not the button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * has keyboard focus (unless there is another component within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * the root pane which consumes the activation event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * such as a <code>JTextPane</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * For default activation to work, the button must be an enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * descendent of the root pane when activation occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * To remove a default button from this root pane, set this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * property to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * @see JButton#isDefaultButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * @param defaultButton the <code>JButton</code> which is to be the default button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     *  description: The button activated by default in this root pane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    public void setDefaultButton(JButton defaultButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        JButton oldDefault = this.defaultButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        if (oldDefault != defaultButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
            this.defaultButton = defaultButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            if (oldDefault != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                oldDefault.repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            if (defaultButton != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                defaultButton.repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        firePropertyChange("defaultButton", oldDefault, defaultButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * Returns the value of the <code>defaultButton</code> property.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @return the <code>JButton</code> which is currently the default button
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * @see #setDefaultButton
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    public JButton getDefaultButton() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        return defaultButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    final void setUseTrueDoubleBuffering(boolean useTrueDoubleBuffering) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        this.useTrueDoubleBuffering = useTrueDoubleBuffering;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    final boolean getUseTrueDoubleBuffering() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        return useTrueDoubleBuffering;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    final void disableTrueDoubleBuffering() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        if (useTrueDoubleBuffering) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
            if (!IGNORE_DISABLE_TRUE_DOUBLE_BUFFERING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                if (LOG_DISABLE_TRUE_DOUBLE_BUFFERING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                    System.out.println("Disabling true double buffering for " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                                       this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                    Thread.dumpStack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                useTrueDoubleBuffering = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                RepaintManager.currentManager(this).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                        doubleBufferingChanged(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
   838
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    static class DefaultAction extends AbstractAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        JButton owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        JRootPane root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        boolean press;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        DefaultAction(JRootPane root, boolean press) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            this.root = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            this.press = press;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        public void setOwner(JButton owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            this.owner = owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        public void actionPerformed(ActionEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            if (owner != null && SwingUtilities.getRootPane(owner) == root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                ButtonModel model = owner.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                if (press) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                    model.setArmed(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                    model.setPressed(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                    model.setPressed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            return owner.getModel().isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * Overridden to enforce the position of the glass component as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * the zero child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * @param comp the component to be enhanced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * @param constraints the constraints to be respected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * @param index the index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    protected void addImpl(Component comp, Object constraints, int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        super.addImpl(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        /// We are making sure the glassPane is on top.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        if(glassPane != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            && glassPane.getParent() == this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            && getComponent(0) != glassPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            add(glassPane, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
///////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
//// Begin Inner Classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
///////////////////////////////////////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * A custom layout manager that is responsible for the layout of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * layeredPane, glassPane, and menuBar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * 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
   901
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
   905
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    protected class RootLayout implements LayoutManager2, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
         * Returns the amount of space the layout would like to have.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
         * @param parent the Container for which this layout manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
         * is being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
         * @return a Dimension object containing the layout's preferred size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        public Dimension preferredLayoutSize(Container parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            Dimension rd, mbd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            Insets i = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            if(contentPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                rd = contentPane.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                rd = parent.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            if(menuBar != null && menuBar.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                mbd = menuBar.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                mbd = new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                                        rd.height + mbd.height + i.top + i.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
         * Returns the minimum amount of space the layout needs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
         * @param parent the Container for which this layout manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
         * is being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
         * @return a Dimension object containing the layout's minimum size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        public Dimension minimumLayoutSize(Container parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            Dimension rd, mbd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            Insets i = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            if(contentPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                rd = contentPane.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                rd = parent.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            if(menuBar != null && menuBar.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                mbd = menuBar.getMinimumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                mbd = new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                        rd.height + mbd.height + i.top + i.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
         * Returns the maximum amount of space the layout can use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
         * @param target the Container for which this layout manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
         * is being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
         * @return a Dimension object containing the layout's maximum size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        public Dimension maximumLayoutSize(Container target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            Dimension rd, mbd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            Insets i = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            if(menuBar != null && menuBar.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                mbd = menuBar.getMaximumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                mbd = new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            if(contentPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                rd = contentPane.getMaximumSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                // This is silly, but should stop an overflow error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                rd = new Dimension(Integer.MAX_VALUE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                        Integer.MAX_VALUE - i.top - i.bottom - mbd.height - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            return new Dimension(Math.min(rd.width, mbd.width) + i.left + i.right,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                                         rd.height + mbd.height + i.top + i.bottom);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
         * Instructs the layout manager to perform the layout for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
         * container.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
         * @param parent the Container for which this layout manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
         * is being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
        public void layoutContainer(Container parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            Rectangle b = parent.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            Insets i = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            int contentY = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            int w = b.width - i.right - i.left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            int h = b.height - i.top - i.bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            if(layeredPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                layeredPane.setBounds(i.left, i.top, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
            if(glassPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                glassPane.setBounds(i.left, i.top, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
            // Note: This is laying out the children in the layeredPane,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            // technically, these are not our children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            if(menuBar != null && menuBar.isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                Dimension mbd = menuBar.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                menuBar.setBounds(0, 0, w, mbd.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                contentY += mbd.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            if(contentPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                contentPane.setBounds(0, contentY, w, h - contentY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        public void addLayoutComponent(String name, Component comp) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        public void removeLayoutComponent(Component comp) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        public void addLayoutComponent(Component comp, Object constraints) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        public float getLayoutAlignmentX(Container target) { return 0.0f; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        public float getLayoutAlignmentY(Container target) { return 0.0f; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        public void invalidateLayout(Container target) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * Returns a string representation of this <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * This method is intended to be used only for debugging purposes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * and the content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * @return  a string representation of this <code>JRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        return super.paramString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * Gets the <code>AccessibleContext</code> associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * <code>JRootPane</code>. For root panes, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * <code>AccessibleContext</code> takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * <code>AccessibleJRootPane</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     * A new <code>AccessibleJRootPane</code> instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     * @return an <code>AccessibleJRootPane</code> that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     *         <code>AccessibleContext</code> of this <code>JRootPane</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            accessibleContext = new AccessibleJRootPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * <code>JRootPane</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * Java Accessibility API appropriate to root pane user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * 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
  1067
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
  1071
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    protected class AccessibleJRootPane extends AccessibleJComponent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
         * @return an instance of AccessibleRole describing the role of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
         * the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            return AccessibleRole.ROOT_PANE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
         * Returns the number of accessible children of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
         * @return the number of accessible children of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            return super.getAccessibleChildrenCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
         * Returns the specified Accessible child of the object.  The Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
         * children of an Accessible object are zero-based, so the first child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
         * of an Accessible child is at index 0, the second child is at index 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
         * and so on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
         * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
         * @return the Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
         * @see #getAccessibleChildrenCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            return super.getAccessibleChild(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
    } // inner class AccessibleJRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
}