553N/A * Copyright (c) 1997, 2006, 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 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/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, 553N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any * An extended version of <code>java.awt.Frame</code> that adds support for * You can find task-oriented documentation about using <code>JFrame</code> * in <em>The Java Tutorial</em>, in the section * The <code>JFrame</code> class is slightly incompatible with <code>Frame</code>. * Like all other JFC/Swing top-level containers, * a <code>JFrame</code> contains a <code>JRootPane</code> as its only child. * The <b>content pane</b> provided by the root pane should, * all the non-menu components displayed by the <code>JFrame</code>. * This is different from the AWT <code>Frame</code> case. * As a conveniance <code>add</code> and its variants, <code>remove</code> and * <code>setLayout</code> have been overridden to forward to the * <code>contentPane</code> as necessary. This means you can write: * And the child will be added to the contentPane. * always be non-null. Attempting to set it to null will cause the JFrame * to throw an exception. The default content pane will have a BorderLayout * Refer to {@link javax.swing.RootPaneContainer} * for details on adding, removing and setting the <code>LayoutManager</code> * of a <code>JFrame</code>. * Unlike a <code>Frame</code>, a <code>JFrame</code> has some notion of how to * respond when the user attempts to close the window. The default behavior * is to simply hide the JFrame when the user closes the window. To change the * default behavior, you invoke the method * {@link #setDefaultCloseOperation}. * To make the <code>JFrame</code> behave the same as a <code>Frame</code> * <code>setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)</code>. * For more information on content panes * and other features that root panes provide, * In a multi-screen environment, you can create a <code>JFrame</code> * on a different screen device. See {@link java.awt.Frame} for more * <strong>Warning:</strong> Swing is not thread safe. For more * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans<sup><font size="-2">TM</font></sup> * has been added to the <code>java.beans</code> package. * @see #setDefaultCloseOperation * @see java.awt.event.WindowListener#windowClosing * @see javax.swing.RootPaneContainer * attribute: isContainer true * attribute: containerDelegate getContentPane * description: A toplevel window which can be minimized to an icon. * The exit application default window close operation. If a window * has this set as the close operation and is closed in an applet, * a <code>SecurityException</code> may be thrown. * It is recommended you only use this in an application. * Key into the AppContext, used to check if should provide decorations * The <code>TransferHandler</code> for this frame. * The <code>JRootPane</code> instance that manages the * <code>contentPane</code> * and optional <code>menuBar</code> for this frame, as well as the * <code>glassPane</code>. * If true then calls to <code>add</code> and <code>setLayout</code> * will be forwarded to the <code>contentPane</code>. This is initially * false, but is set to true when the <code>JFrame</code> is constructed. * @see #isRootPaneCheckingEnabled * @see #setRootPaneCheckingEnabled * @see javax.swing.RootPaneContainer * Constructs a new frame that is initially invisible. * This constructor sets the component's locale property to the value * returned by <code>JComponent.getDefaultLocale</code>. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * @see Component#setVisible * @see JComponent#getDefaultLocale * Creates a <code>Frame</code> in the specified * <code>GraphicsConfiguration</code> of * a screen device and a blank title. * This constructor sets the component's locale property to the value * returned by <code>JComponent.getDefaultLocale</code>. * @param gc the <code>GraphicsConfiguration</code> that is used * to construct the new <code>Frame</code>; * if <code>gc</code> is <code>null</code>, the system * default <code>GraphicsConfiguration</code> is assumed * @exception IllegalArgumentException if <code>gc</code> is not from * a screen device. This exception is always thrown when * GraphicsEnvironment.isHeadless() returns true. * @see java.awt.GraphicsEnvironment#isHeadless * @see JComponent#getDefaultLocale * Creates a new, initially invisible <code>Frame</code> with the * This constructor sets the component's locale property to the value * returned by <code>JComponent.getDefaultLocale</code>. * @param title the title for the frame * @exception HeadlessException if GraphicsEnvironment.isHeadless() * @see java.awt.GraphicsEnvironment#isHeadless * @see Component#setVisible * @see JComponent#getDefaultLocale * Creates a <code>JFrame</code> with the specified title and the * specified <code>GraphicsConfiguration</code> of a screen device. * This constructor sets the component's locale property to the value * returned by <code>JComponent.getDefaultLocale</code>. * @param title the title to be displayed in the * frame's border. A <code>null</code> value is treated as * @param gc the <code>GraphicsConfiguration</code> that is used * to construct the new <code>JFrame</code> with; * if <code>gc</code> is <code>null</code>, the system * default <code>GraphicsConfiguration</code> is assumed * @exception IllegalArgumentException if <code>gc</code> is not from * a screen device. This exception is always thrown when * GraphicsEnvironment.isHeadless() returns true. * @see java.awt.GraphicsEnvironment#isHeadless * @see JComponent#getDefaultLocale /** Called by the constructors to init the <code>JFrame</code> properly. */ * Called by the constructor methods to create the default // NOTE: this uses setOpaque vs LookAndFeel.installProperty as there // is NO reason for the RootPane not to be opaque. For painting to // work the contentPane must be opaque, therefor the RootPane can * Processes window events occurring on this component. * Hides the window or disposes of it, as specified by the setting * of the <code>defaultCloseOperation</code> property. * @param e the window event * @see #setDefaultCloseOperation * @see java.awt.Window#processWindowEvent // This needs to match the checkExit call in // setDefaultCloseOperation // public void setMenuBar(MenuBar menu) { // throw new IllegalComponentStateException("Please use setJMenuBar() with JFrame."); * Sets the operation that will happen by default when * the user initiates a "close" on this frame. * You must specify one of the following choices: * <li><code>DO_NOTHING_ON_CLOSE</code> * (defined in <code>WindowConstants</code>): * Don't do anything; require the * program to handle the operation in the <code>windowClosing</code> * method of a registered <code>WindowListener</code> object. * <li><code>HIDE_ON_CLOSE</code> * (defined in <code>WindowConstants</code>): * Automatically hide the frame after * invoking any registered <code>WindowListener</code> * <li><code>DISPOSE_ON_CLOSE</code> * (defined in <code>WindowConstants</code>): * Automatically hide and dispose the * frame after invoking any registered <code>WindowListener</code> * <li><code>EXIT_ON_CLOSE</code> * (defined in <code>JFrame</code>): * Exit the application using the <code>System</code> * <code>exit</code> method. Use this only in applications. * The value is set to <code>HIDE_ON_CLOSE</code> by default. Changes * to the value of this property cause the firing of a property * change event, with property name "defaultCloseOperation". * <b>Note</b>: When the last displayable window within the * Java virtual machine (VM) is disposed of, the VM may * AWT Threading Issues</a> for more information. * @param operation the operation which should be performed when the * @exception IllegalArgumentException if defaultCloseOperation value * isn't one of the above valid values * @see #addWindowListener * @see #getDefaultCloseOperation * @throws SecurityException * if <code>EXIT_ON_CLOSE</code> has been specified and the * <code>SecurityManager</code> will * not allow the caller to invoke <code>System.exit</code> * @see java.lang.Runtime#exit(int) * enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE * HIDE_ON_CLOSE WindowConstants.HIDE_ON_CLOSE * DISPOSE_ON_CLOSE WindowConstants.DISPOSE_ON_CLOSE * EXIT_ON_CLOSE WindowConstants.EXIT_ON_CLOSE * description: The frame's default close operation. throw new IllegalArgumentException(
"defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE");
* Returns the operation that occurs when the user * initiates a "close" on this frame. * @return an integer indicating the window-close operation * @see #setDefaultCloseOperation * Sets the {@code transferHandler} property, which is a mechanism to * support transfer of data into this component. Use {@code null} * if the component does not support data transfer operations. * If the system property {@code suppressSwingDropSupport} is {@code false} * (the default) and the current drop target on this component is either * {@code null} or not a user-set drop target, this method will change the * drop target as follows: If {@code newHandler} is {@code null} it will * clear the drop target. If not {@code null} it will install a new * Note: When used with {@code JFrame}, {@code TransferHandler} only * provides data import capability, as the data export related methods * are currently typed to {@code JComponent}. * How to Use Drag and Drop and Data Transfer</a>, a section in * <em>The Java Tutorial</em>, for more information. * @param newHandler the new {@code TransferHandler} * @see #getTransferHandler * @see java.awt.Component#setDropTarget * description: Mechanism for transfer of data into the component * Gets the <code>transferHandler</code> property. * @return the value of the <code>transferHandler</code> property * @see #setTransferHandler * Just calls <code>paint(g)</code>. This method was overridden to * prevent an unnecessary call to clear the background. * @param g the Graphics context in which to paint * Sets the menubar for this frame. * @param menubar the menubar being placed in the frame * description: The menubar for accessing pulldown menus from this frame. * Returns the menubar set on this frame. * @return the menubar for this frame * Returns whether calls to <code>add</code> and * <code>setLayout</code> are forwarded to the <code>contentPane</code>. * @return true if <code>add</code> and <code>setLayout</code> * are fowarded; false otherwise * @see #setRootPaneCheckingEnabled * @see javax.swing.RootPaneContainer * Sets whether calls to <code>add</code> and * <code>setLayout</code> are forwarded to the <code>contentPane</code>. * @param enabled true if <code>add</code> and <code>setLayout</code> * are forwarded, false if they should operate directly on the * @see #isRootPaneCheckingEnabled * @see javax.swing.RootPaneContainer * description: Whether the add and setLayout methods are forwarded * Adds the specified child <code>Component</code>. * This method is overridden to conditionally forward calls to the * <code>contentPane</code>. * By default, children are added to the <code>contentPane</code> instead * of the frame, refer to {@link javax.swing.RootPaneContainer} for * @param comp the component to be enhanced * @param constraints the constraints to be respected * @exception IllegalArgumentException if <code>index</code> is invalid * @exception IllegalArgumentException if adding the container's parent * @exception IllegalArgumentException if adding a window to a container * @see #setRootPaneCheckingEnabled * @see javax.swing.RootPaneContainer * Removes the specified component from the container. If * <code>comp</code> is not the <code>rootPane</code>, this will forward * the call to the <code>contentPane</code>. This will do nothing if * <code>comp</code> is not a child of the <code>JFrame</code> or * <code>contentPane</code>. * @param comp the component to be removed * @throws NullPointerException if <code>comp</code> is null * @see javax.swing.RootPaneContainer * Sets the <code>LayoutManager</code>. * Overridden to conditionally forward the call to the * <code>contentPane</code>. * Refer to {@link javax.swing.RootPaneContainer} for * @param manager the <code>LayoutManager</code> * @see #setRootPaneCheckingEnabled * @see javax.swing.RootPaneContainer * Returns the <code>rootPane</code> object for this frame. * @return the <code>rootPane</code> property * @see RootPaneContainer#getRootPane * Sets the <code>rootPane</code> property. * This method is called by the constructor. * @param root the <code>rootPane</code> object for this frame * description: the RootPane object for this frame. * Returns the <code>contentPane</code> object for this frame. * @return the <code>contentPane</code> property * @see RootPaneContainer#getContentPane * Sets the <code>contentPane</code> property. * This method is called by the constructor. * Swing's painting architecture requires an opaque <code>JComponent</code> * in the containment hiearchy. This is typically provided by the * content pane. If you replace the content pane it is recommended you * replace it with an opaque <code>JComponent</code>. * @param contentPane the <code>contentPane</code> object for this frame * @exception java.awt.IllegalComponentStateException (a runtime * exception) if the content pane parameter is <code>null</code> * @see RootPaneContainer#setContentPane * description: The client area of the frame where child * components are normally inserted. * Returns the <code>layeredPane</code> object for this frame. * @return the <code>layeredPane</code> property * @see RootPaneContainer#getLayeredPane * Sets the <code>layeredPane</code> property. * This method is called by the constructor. * @param layeredPane the <code>layeredPane</code> object for this frame * @exception java.awt.IllegalComponentStateException (a runtime * exception) if the layered pane parameter is <code>null</code> * @see RootPaneContainer#setLayeredPane * description: The pane that holds the various frame layers. * Returns the <code>glassPane</code> object for this frame. * @return the <code>glassPane</code> property * @see RootPaneContainer#getGlassPane * Sets the <code>glassPane</code> property. * This method is called by the constructor. * @param glassPane the <code>glassPane</code> object for this frame * @see RootPaneContainer#setGlassPane * description: A transparent pane used for menu rendering. * Repaints the specified rectangle of this component within * <code>time</code> milliseconds. Refer to <code>RepaintManager</code> * for details on how the repaint is handled. * @param time maximum time in milliseconds before update * @param x the <i>x</i> coordinate * @param y the <i>y</i> coordinate * @param height the height * Provides a hint as to whether or not newly created <code>JFrame</code>s * should have their Window decorations (such as borders, widgets to * close the window, title...) provided by the current look * and feel. If <code>defaultLookAndFeelDecorated</code> is true, * the current <code>LookAndFeel</code> supports providing window * decorations, and the current window manager supports undecorated * windows, then newly created <code>JFrame</code>s will have their * Window decorations provided by the current <code>LookAndFeel</code>. * Otherwise, newly created <code>JFrame</code>s will have their * Window decorations provided by the current window manager. * You can get the same effect on a single JFrame by doing the following: * JFrame frame = new JFrame(); * frame.setUndecorated(true); * frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); * @param defaultLookAndFeelDecorated A hint as to whether or not current * look and feel should provide window decorations * @see javax.swing.LookAndFeel#getSupportsWindowDecorations * Returns true if newly created <code>JFrame</code>s should have their * Window decorations provided by the current look and feel. This is only * a hint, as certain look and feels may not support this feature. * @return true if look and feel should provide Window decorations. * Returns a string representation of this <code>JFrame</code>. * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not * @return a string representation of this <code>JFrame</code> /** The accessible context property. */ * Gets the AccessibleContext associated with this JFrame. * For JFrames, the AccessibleContext takes the form of an * A new AccessibleJFrame instance is created if necessary. * @return an AccessibleJFrame that serves as the * AccessibleContext of this JFrame * This class implements accessibility support for the * <code>JFrame</code> class. It provides an implementation of the * Java Accessibility API appropriate to frame user-interface // AccessibleContext methods * Get the accessible name of this object. * @return the localized name of the object -- can be null if this * object does not have a name * Get the state of this object. * @return an instance of AccessibleStateSet containing the current * state set of the object // FIXME: [[[WDW - should also return ICONIFIED and ICONIFIABLE // if we can ever figure these out]]] }
// inner class AccessibleJFrame