2362N/A * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A lightweight container used behind the scenes by 0N/A * <code>JFrame</code>, <code>JDialog</code>, <code>JWindow</code>, 0N/A * <code>JApplet</code>, and <code>JInternalFrame</code>. 0N/A * For task-oriented information on functionality provided by root panes 0N/A * a section in <em>The Java Tutorial</em>. 0N/A * The following image shows the relationships between 0N/A * the classes that use root panes. 0N/A * alt="The following text describes this graphic." 0N/A * HEIGHT=484 WIDTH=629></p> 0N/A * The "heavyweight" components (those that delegate to a peer, or native 0N/A * component on the host system) are shown with a darker, heavier box. The four 0N/A * heavyweight JFC/Swing containers (<code>JFrame</code>, <code>JDialog</code>, 0N/A * <code>JWindow</code>, and <code>JApplet</code>) are 0N/A * shown in relation to the AWT classes they extend. 0N/A * These four components are the 0N/A * only heavyweight containers in the Swing library. The lightweight container 0N/A * <code>JInternalFrame</code> is also shown. 0N/A * <code>RootPaneContainer</code> interface, 0N/A * and they all delegate their operations to a 0N/A * <code>JRootPane</code> (shown with a little "handle" on top). 0N/A * <b>Note:</b> The <code>JComponent</code> method <code>getRootPane</code> 0N/A * can be used to obtain the <code>JRootPane</code> that contains 0N/A * a given component. 0N/A * <table align="right" border="0" summary="layout"> 0N/A * <td align="center"> 0N/A * alt="The following text describes this graphic." HEIGHT=386 WIDTH=349> 0N/A * The diagram at right shows the structure of a <code>JRootPane</code>. 0N/A * A <code>JRootpane</code> is made up of a <code>glassPane</code>, 0N/A * an optional <code>menuBar</code>, and a <code>contentPane</code>. 0N/A * (The <code>JLayeredPane</code> manages the <code>menuBar</code> 0N/A * and the <code>contentPane</code>.) 0N/A * The <code>glassPane</code> sits over the top of everything, 0N/A * where it is in a position to intercept mouse movements. 0N/A * Since the <code>glassPane</code> (like the <code>contentPane</code>) 0N/A * can be an arbitrary component, it is also possible to set up the 0N/A * <code>glassPane</code> for drawing. Lines and images on the 0N/A * <code>glassPane</code> can then range 0N/A * over the frames underneath without being limited by their boundaries. 0N/A * Although the <code>menuBar</code> component is optional, 0N/A * the <code>layeredPane</code>, <code>contentPane</code>, 0N/A * and <code>glassPane</code> always exist. 0N/A * Attempting to set them to <code>null</code> generates an exception. 0N/A * To add components to the <code>JRootPane</code> (other than the 0N/A * optional menu bar), you add the object to the <code>contentPane</code> 0N/A * of the <code>JRootPane</code>, like this: 0N/A * rootPane.getContentPane().add(child); 0N/A * The same principle holds true for setting layout managers, removing 0N/A * components, listing children, etc. All these methods are invoked on 0N/A * the <code>contentPane</code> instead of on the <code>JRootPane</code>. 0N/A * <b>Note:</b> The default layout manager for the <code>contentPane</code> is 0N/A * a <code>BorderLayout</code> manager. However, the <code>JRootPane</code> 0N/A * uses a custom <code>LayoutManager</code>. 0N/A * So, when you want to change the layout manager for the components you added 0N/A * to a <code>JRootPane</code>, be sure to use code like this: 0N/A * rootPane.getContentPane().setLayout(new BoxLayout()); 0N/A * </pre></blockquote> 0N/A * If a <code>JMenuBar</code> component is set on the <code>JRootPane</code>, 0N/A * it is positioned along the upper edge of the frame. 0N/A * The <code>contentPane</code> is adjusted in location and size to 0N/A * fill the remaining area. 0N/A * (The <code>JMenuBar</code> and the <code>contentPane</code> are added to the 0N/A * <code>layeredPane</code> component at the 0N/A * <code>JLayeredPane.FRAME_CONTENT_LAYER</code> layer.) 0N/A * The <code>layeredPane</code> is the parent of all children in the 0N/A * <code>JRootPane</code> -- both as the direct parent of the menu and 0N/A * the grandparent of all components added to the <code>contentPane</code>. 0N/A * It is an instance of <code>JLayeredPane</code>, 0N/A * which provides the ability to add components at several layers. 0N/A * This capability is very useful when working with menu popups, 0N/A * dialog boxes, and dragging -- situations in which you need to place 0N/A * a component on top of all other components in the pane. 0N/A * The <code>glassPane</code> sits on top of all other components in the 0N/A * <code>JRootPane</code>. 0N/A * That provides a convenient place to draw above all other components, 0N/A * and makes it possible to intercept mouse events, 0N/A * which is useful both for dragging and for drawing. 0N/A * Developers can use <code>setVisible</code> on the <code>glassPane</code> 0N/A * to control when the <code>glassPane</code> displays over the other children. 0N/A * By default the <code>glassPane</code> is not visible. 0N/A * The custom <code>LayoutManager</code> used by <code>JRootPane</code> 0N/A * <LI>The <code>glassPane</code> fills the entire viewable 0N/A * area of the <code>JRootPane</code> (bounds - insets). 0N/A * <LI>The <code>layeredPane</code> fills the entire viewable area of the 0N/A * <code>JRootPane</code>. (bounds - insets) 0N/A * <LI>The <code>menuBar</code> is positioned at the upper edge of the 0N/A * <code>layeredPane</code>. 0N/A * <LI>The <code>contentPane</code> fills the entire viewable area, 0N/A * minus the <code>menuBar</code>, if present. 0N/A * Any other views in the <code>JRootPane</code> view hierarchy are ignored. 0N/A * If you replace the <code>LayoutManager</code> of the <code>JRootPane</code>, 0N/A * you are responsible for managing all of these views. 0N/A * So ordinarily you will want to be sure that you 0N/A * change the layout manager for the <code>contentPane</code> rather than 0N/A * for the <code>JRootPane</code> itself! 0N/A * The painting architecture of Swing requires an opaque 0N/A * <code>JComponent</code> 0N/A * to exist in the containment hieararchy above all other components. This is 0N/A * typically provided by way of the content pane. If you replace the content 0N/A * pane, it is recommended that you make the content pane opaque 0N/A * by way of <code>setOpaque(true)</code>. Additionally, if the content pane 0N/A * overrides <code>paintComponent</code>, it 0N/A * will need to completely fill in the background in an opaque color in 0N/A * <code>paintComponent</code>. 0N/A * <strong>Warning:</strong> Swing is not thread safe. For more 0N/A * information see <a 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * @see JInternalFrame 0N/A * Mixing Heavy and Light Components</a> 0N/A * @author David Kloba 0N/A/// PENDING(klobad) Who should be opaque in this component? 0N/A * Whether or not we should dump the stack when true double buffering 0N/A * is disabled. Default is false. 0N/A * Whether or not we should ignore requests to disable true double 0N/A * buffering. Default is false. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should not provide any sort of 0N/A * Window decorations. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * a Dialog used to display an informational message. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * a Dialog used to display an error message. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * a Dialog used to display a <code>JColorChooser</code>. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * a Dialog used to display a <code>JFileChooser</code>. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * a Dialog used to present a question to the user. 0N/A * Constant used for the windowDecorationStyle property. Indicates that 0N/A * the <code>JRootPane</code> should provide decorations appropriate for 0N/A * a Dialog used to display a warning message. 0N/A /** The menu bar. */ 0N/A /** The content pane. */ 0N/A /** The layered pane that manages the menu bar and content pane. */ 0N/A * The glass pane that overlays the menu bar and content pane, 0N/A * so it can intercept mouse movements and such. 0N/A * The button that gets activated when the pane has the focus and 0N/A * a UI-specific action like pressing the <b>Enter</b> key occurs. 0N/A * As of Java 2 platform v1.3 this unusable field is no longer used. 0N/A * To override the default button you should replace the <code>Action</code> 0N/A * in the <code>JRootPane</code>'s <code>ActionMap</code>. Please refer to 0N/A * the key bindings specification for further details. 0N/A * @deprecated As of Java 2 platform v1.3. 0N/A * @see #defaultButton 0N/A * As of Java 2 platform v1.3 this unusable field is no longer used. 0N/A * To override the default button you should replace the <code>Action</code> 0N/A * in the <code>JRootPane</code>'s <code>ActionMap</code>. Please refer to 0N/A * the key bindings specification for further details. 0N/A * @deprecated As of Java 2 platform v1.3. 0N/A * @see #defaultButton 0N/A * Whether or not true double buffering should be used. This is typically 0N/A * true, but may be set to false in special situations. For example, 0N/A * heavy weight popups (backed by a window) set this to false. 0N/A "swing.logDoubleBufferingDisable"));
0N/A "swing.ignoreDoubleBufferingDisable"));
0N/A * Creates a <code>JRootPane</code>, setting up its 0N/A * <code>glassPane</code>, <code>layeredPane</code>, 0N/A * and <code>contentPane</code>. 0N/A * Returns a constant identifying the type of Window decorations the 0N/A * <code>JRootPane</code> is providing. 0N/A * @return One of <code>NONE</code>, <code>FRAME</code>, 0N/A * <code>PLAIN_DIALOG</code>, <code>INFORMATION_DIALOG</code>, 0N/A * <code>ERROR_DIALOG</code>, <code>COLOR_CHOOSER_DIALOG</code>, 0N/A * <code>FILE_CHOOSER_DIALOG</code>, <code>QUESTION_DIALOG</code> or 0N/A * <code>WARNING_DIALOG</code>. 0N/A * @see #setWindowDecorationStyle 0N/A * Sets the type of Window decorations (such as borders, widgets for 0N/A * closing a Window, title ...) the <code>JRootPane</code> should 0N/A * provide. The default is to provide no Window decorations 0N/A * (<code>NONE</code>). 0N/A * This is only a hint, and some look and feels may not support 0N/A * This is a bound property. 0N/A * @param windowDecorationStyle Constant identifying Window decorations 0N/A * @see JDialog#setDefaultLookAndFeelDecorated 0N/A * @see JFrame#setDefaultLookAndFeelDecorated 0N/A * @see LookAndFeel#getSupportsWindowDecorations 0N/A * @throws IllegalArgumentException if <code>style</code> is 0N/A * not one of: <code>NONE</code>, <code>FRAME</code>, 0N/A * <code>PLAIN_DIALOG</code>, <code>INFORMATION_DIALOG</code>, 0N/A * <code>ERROR_DIALOG</code>, <code>COLOR_CHOOSER_DIALOG</code>, 0N/A * <code>FILE_CHOOSER_DIALOG</code>, <code>QUESTION_DIALOG</code>, or 0N/A * <code>WARNING_DIALOG</code>. 0N/A * enum: NONE JRootPane.NONE 0N/A * FRAME JRootPane.FRAME 0N/A * PLAIN_DIALOG JRootPane.PLAIN_DIALOG 0N/A * INFORMATION_DIALOG JRootPane.INFORMATION_DIALOG 0N/A * ERROR_DIALOG JRootPane.ERROR_DIALOG 0N/A * COLOR_CHOOSER_DIALOG JRootPane.COLOR_CHOOSER_DIALOG 0N/A * FILE_CHOOSER_DIALOG JRootPane.FILE_CHOOSER_DIALOG 0N/A * QUESTION_DIALOG JRootPane.QUESTION_DIALOG 0N/A * WARNING_DIALOG JRootPane.WARNING_DIALOG 0N/A * attribute: visualUpdate true 0N/A * description: Identifies the type of Window decorations to provide 0N/A * Returns the L&F object that renders this component. 0N/A * @return <code>LabelUI</code> object 0N/A * Sets the L&F object that renders this component. 0N/A * @param ui the <code>LabelUI</code> L&F object 0N/A * @see UIDefaults#getUI 0N/A * attribute: visualUpdate true 0N/A * description: The UI object that implements the Component's LookAndFeel. 0N/A * Resets the UI property to a value from the current look and feel. 0N/A * @see JComponent#updateUI 0N/A * Returns a string that specifies the name of the L&F class 0N/A * that renders this component. 0N/A * @return the string "RootPaneUI" 0N/A * @see JComponent#getUIClassID 0N/A * @see UIDefaults#getUI 0N/A * Called by the constructor methods to create the default 0N/A * <code>layeredPane</code>. 0N/A * Bt default it creates a new <code>JLayeredPane</code>. 0N/A * @return the default <code>layeredPane</code> 0N/A * Called by the constructor methods to create the default 0N/A * <code>contentPane</code>. 0N/A * By default this method creates a new <code>JComponent</code> add sets a 0N/A * <code>BorderLayout</code> as its <code>LayoutManager</code>. 0N/A * @return the default <code>contentPane</code> 0N/A /* This BorderLayout subclass maps a null constraint to CENTER. 0N/A * Although the reference BorderLayout also does this, some VMs 0N/A * throw an IllegalArgumentException. 0N/A * Called by the constructor methods to create the default 0N/A * <code>glassPane</code>. 0N/A * By default this method creates a new <code>JComponent</code> 0N/A * with visibility set to false. 0N/A * @return the default <code>glassPane</code> 0N/A * Called by the constructor methods to create the default 0N/A * <code>layoutManager</code>. 0N/A * @return the default <code>layoutManager</code>. 0N/A * Adds or changes the menu bar used in the layered pane. 0N/A * @param menu the <code>JMenuBar</code> to add 0N/A * Specifies the menu bar value. 0N/A * @deprecated As of Swing version 1.0.3 0N/A * replaced by <code>setJMenuBar(JMenuBar menu)</code>. 0N/A * @param menu the <code>JMenuBar</code> to add. 0N/A * Returns the menu bar from the layered pane. 0N/A * @return the <code>JMenuBar</code> used in the pane 0N/A * Returns the menu bar value. 0N/A * @deprecated As of Swing version 1.0.3 0N/A * replaced by <code>getJMenuBar()</code>. 0N/A * @return the <code>JMenuBar</code> used in the pane 0N/A * Sets the content pane -- the container that holds the components 0N/A * parented by the root pane. 0N/A * Swing's painting architecture requires an opaque <code>JComponent</code> 0N/A * in the containment hiearchy. This is typically provided by the 0N/A * content pane. If you replace the content pane it is recommended you 0N/A * replace it with an opaque <code>JComponent</code>. 0N/A * @param content the <code>Container</code> to use for component-contents 0N/A * @exception java.awt.IllegalComponentStateException (a runtime 0N/A * exception) if the content pane parameter is <code>null</code> 0N/A * Returns the content pane -- the container that holds the components 0N/A * parented by the root pane. 0N/A * @return the <code>Container</code> that holds the component-contents 0N/A// PENDING(klobad) Should this reparent the contentPane and MenuBar? 0N/A * Sets the layered pane for the root pane. The layered pane 0N/A * typically holds a content pane and an optional <code>JMenuBar</code>. 0N/A * @param layered the <code>JLayeredPane</code> to use 0N/A * @exception java.awt.IllegalComponentStateException (a runtime 0N/A * exception) if the layered pane parameter is <code>null</code> 0N/A * Gets the layered pane used by the root pane. The layered pane 0N/A * typically holds a content pane and an optional <code>JMenuBar</code>. 0N/A * @return the <code>JLayeredPane</code> currently in use 0N/A * Sets a specified <code>Component</code> to be the glass pane for this 0N/A * root pane. The glass pane should normally be a lightweight, 0N/A * transparent component, because it will be made visible when 0N/A * ever the root pane needs to grab input events. 0N/A * The new glass pane's visibility is changed to match that of 0N/A * the current glass pane. An implication of this is that care 0N/A * must be taken when you want to replace the glass pane and 0N/A * make it visible. Either of the following will work: 0N/A * root.setGlassPane(newGlassPane); 0N/A * newGlassPane.setVisible(true); 0N/A * root.getGlassPane().setVisible(true); 0N/A * root.setGlassPane(newGlassPane); 0N/A * @param glass the <code>Component</code> to use as the glass pane 0N/A * for this <code>JRootPane</code> 0N/A * @exception NullPointerException if the <code>glass</code> parameter is 0N/A * Returns the current glass pane for this <code>JRootPane</code>. 0N/A * @return the current glass pane 0N/A * @see #setGlassPane 0N/A * If a descendant of this <code>JRootPane</code> calls 0N/A * <code>revalidate</code>, validate from here on down. 0N/A * Deferred requests to layout a component and its descendents again. 0N/A * For example, calls to <code>revalidate</code>, are pushed upwards to 0N/A * either a <code>JRootPane</code> or a <code>JScrollPane</code> 0N/A * because both classes override <code>isValidateRoot</code> to return true. 0N/A * @see JComponent#isValidateRoot 1895N/A * @see java.awt.Container#isValidateRoot 0N/A * The <code>glassPane</code> and <code>contentPane</code> 0N/A * have the same bounds, which means <code>JRootPane</code> 0N/A * does not tiles its children and this should return false. 0N/A * On the other hand, the <code>glassPane</code> 0N/A * is normally not visible, and so this can return true if the 0N/A * <code>glassPane</code> isn't visible. Therefore, the 0N/A * return value here depends upon the visiblity of the 0N/A * <code>glassPane</code>. 0N/A * @return true if this component's children don't overlap 0N/A * Sets the <code>defaultButton</code> property, 0N/A * which determines the current default button for this <code>JRootPane</code>. 0N/A * The default button is the button which will be activated 0N/A * when a UI-defined activation event (typically the <b>Enter</b> key) 0N/A * occurs in the root pane regardless of whether or not the button 0N/A * has keyboard focus (unless there is another component within 0N/A * the root pane which consumes the activation event, 0N/A * such as a <code>JTextPane</code>). 0N/A * For default activation to work, the button must be an enabled 0N/A * descendent of the root pane when activation occurs. 0N/A * To remove a default button from this root pane, set this 0N/A * property to <code>null</code>. 0N/A * @see JButton#isDefaultButton 0N/A * @param defaultButton the <code>JButton</code> which is to be the default button 0N/A * description: The button activated by default in this root pane 0N/A * Returns the value of the <code>defaultButton</code> property. 0N/A * @return the <code>JButton</code> which is currently the default button 0N/A * @see #setDefaultButton 0N/A * Overridden to enforce the position of the glass component as 0N/A * @param comp the component to be enhanced 0N/A * @param constraints the constraints to be respected 0N/A * @param index the index 0N/A /// We are making sure the glassPane is on top. 0N/A/////////////////////////////////////////////////////////////////////////////// 0N/A//// Begin Inner Classes 0N/A/////////////////////////////////////////////////////////////////////////////// 0N/A * A custom layout manager that is responsible for the layout of 0N/A * layeredPane, glassPane, and menuBar. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * Returns the amount of space the layout would like to have. 0N/A * @param parent the Container for which this layout manager 0N/A * @return a Dimension object containing the layout's preferred size 0N/A * Returns the minimum amount of space the layout needs. 0N/A * @param parent the Container for which this layout manager 0N/A * @return a Dimension object containing the layout's minimum size 0N/A * Returns the maximum amount of space the layout can use. 0N/A * @param target the Container for which this layout manager 0N/A * @return a Dimension object containing the layout's maximum size 0N/A // This is silly, but should stop an overflow error 0N/A * Instructs the layout manager to perform the layout for the specified 0N/A * @param parent the Container for which this layout manager 0N/A // Note: This is laying out the children in the layeredPane, 0N/A // technically, these are not our children. 0N/A * Returns a string representation of this <code>JRootPane</code>. 0N/A * This method is intended to be used only for debugging purposes, 0N/A * and the content and format of the returned string may vary between 0N/A * implementations. The returned string may be empty but may not 0N/A * be <code>null</code>. 0N/A * @return a string representation of this <code>JRootPane</code>. 0N/A// Accessibility support 0N/A * Gets the <code>AccessibleContext</code> associated with this 0N/A * <code>JRootPane</code>. For root panes, the 0N/A * <code>AccessibleContext</code> takes the form of an 0N/A * <code>AccessibleJRootPane</code>. 0N/A * A new <code>AccessibleJRootPane</code> instance is created if necessary. 0N/A * @return an <code>AccessibleJRootPane</code> that serves as the 0N/A * <code>AccessibleContext</code> of this <code>JRootPane</code> 0N/A * This class implements accessibility support for the 0N/A * <code>JRootPane</code> class. It provides an implementation of the 0N/A * Java Accessibility API appropriate to root pane user-interface elements. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A * Get the role of this object. 0N/A * @return an instance of AccessibleRole describing the role of 0N/A * Returns the number of accessible children of the object. 0N/A * @return the number of accessible children of the object. 0N/A * Returns the specified Accessible child of the object. The Accessible 0N/A * children of an Accessible object are zero-based, so the first child 0N/A * of an Accessible child is at index 0, the second child is at index 1, 0N/A * @param i zero-based index of child 0N/A * @return the Accessible child of the object 0N/A * @see #getAccessibleChildrenCount 0N/A }
// inner class AccessibleJRootPane