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