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