< prev index next >
src/java.desktop/share/classes/javax/swing/JFrame.java
Print this page
@@ -41,25 +41,25 @@
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
/**
- * An extended version of <code>java.awt.Frame</code> that adds support for
+ * An extended version of {@code java.awt.Frame} that adds support for
* the JFC/Swing component architecture.
- * You can find task-oriented documentation about using <code>JFrame</code>
+ * You can find task-oriented documentation about using {@code JFrame}
* in <em>The Java Tutorial</em>, in the section
* <a
href="http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html">How to Make Frames</a>.
*
* <p>
- * The <code>JFrame</code> class is slightly incompatible with <code>Frame</code>.
+ * The {@code JFrame} class is slightly incompatible with {@code Frame}.
* Like all other JFC/Swing top-level containers,
- * a <code>JFrame</code> contains a <code>JRootPane</code> as its only child.
+ * a {@code JFrame} contains a {@code JRootPane} as its only child.
* The <b>content pane</b> provided by the root pane should,
* as a rule, contain
- * all the non-menu components displayed by the <code>JFrame</code>.
- * This is different from the AWT <code>Frame</code> case.
+ * all the non-menu components displayed by the {@code JFrame}.
+ * This is different from the AWT {@code Frame} case.
* As a convenience, the {@code add}, {@code remove}, and {@code setLayout}
* methods of this class are overridden, so that they delegate calls
* to the corresponding methods of the {@code ContentPane}.
* For example, you can add a child component to a frame as follows:
* <pre>
@@ -69,28 +69,28 @@
* The content pane will
* 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
* manager set on it.
* Refer to {@link javax.swing.RootPaneContainer}
- * for details on adding, removing and setting the <code>LayoutManager</code>
- * of a <code>JFrame</code>.
+ * for details on adding, removing and setting the {@code LayoutManager}
+ * of a {@code JFrame}.
* <p>
- * Unlike a <code>Frame</code>, a <code>JFrame</code> has some notion of how to
+ * Unlike a {@code Frame}, a {@code JFrame} 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>
+ * To make the {@code JFrame} behave the same as a {@code Frame}
* instance, use
- * <code>setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)</code>.
+ * {@code setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)}.
* <p>
* For more information on content panes
* and other features that root panes provide,
* see <a
href="http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html">Using Top-Level Containers</a> in <em>The Java Tutorial</em>.
* <p>
- * In a multi-screen environment, you can create a <code>JFrame</code>
+ * In a multi-screen environment, you can create a {@code JFrame}
* on a different screen device. See {@link java.awt.Frame} for more
* information.
* <p>
* <strong>Warning:</strong> Swing is not thread safe. For more
* information see <a
@@ -101,11 +101,11 @@
* 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™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see JRootPane
* @see #setDefaultCloseOperation
* @see java.awt.event.WindowListener#windowClosing
@@ -135,29 +135,29 @@
new StringBuffer("JFrame.defaultLookAndFeelDecorated");
private int defaultCloseOperation = HIDE_ON_CLOSE;
/**
- * The <code>TransferHandler</code> for this frame.
+ * The {@code TransferHandler} for this frame.
*/
private TransferHandler transferHandler;
/**
- * 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>.
+ * The {@code JRootPane} instance that manages the
+ * {@code contentPane}
+ * and optional {@code menuBar} for this frame, as well as the
+ * {@code glassPane}.
*
* @see JRootPane
* @see RootPaneContainer
*/
protected JRootPane rootPane;
/**
- * 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.
+ * If true then calls to {@code add} and {@code setLayout}
+ * will be forwarded to the {@code contentPane}. This is initially
+ * false, but is set to true when the {@code JFrame} is constructed.
*
* @see #isRootPaneCheckingEnabled
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
@@ -166,11 +166,11 @@
/**
* Constructs a new frame that is initially invisible.
* <p>
* This constructor sets the component's locale property to the value
- * returned by <code>JComponent.getDefaultLocale</code>.
+ * returned by {@code JComponent.getDefaultLocale}.
*
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
* @see Component#setSize
@@ -181,22 +181,22 @@
super();
frameInit();
}
/**
- * Creates a <code>Frame</code> in the specified
- * <code>GraphicsConfiguration</code> of
+ * Creates a {@code Frame} in the specified
+ * {@code GraphicsConfiguration} of
* a screen device and a blank title.
* <p>
* This constructor sets the component's locale property to the value
- * returned by <code>JComponent.getDefaultLocale</code>.
+ * returned by {@code JComponent.getDefaultLocale}.
*
- * @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
+ * @param gc the {@code GraphicsConfiguration} that is used
+ * to construct the new {@code Frame};
+ * if {@code gc} is {@code null}, the system
+ * default {@code GraphicsConfiguration} is assumed
+ * @exception IllegalArgumentException if {@code gc} is not from
* a screen device. This exception is always thrown when
* GraphicsEnvironment.isHeadless() returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
* @see JComponent#getDefaultLocale
* @since 1.3
@@ -205,15 +205,15 @@
super(gc);
frameInit();
}
/**
- * Creates a new, initially invisible <code>Frame</code> with the
+ * Creates a new, initially invisible {@code Frame} with the
* specified title.
* <p>
* This constructor sets the component's locale property to the value
- * returned by <code>JComponent.getDefaultLocale</code>.
+ * returned by {@code JComponent.getDefaultLocale}.
*
* @param title the title for the frame
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
@@ -225,24 +225,24 @@
super(title);
frameInit();
}
/**
- * Creates a <code>JFrame</code> with the specified title and the
- * specified <code>GraphicsConfiguration</code> of a screen device.
+ * Creates a {@code JFrame} with the specified title and the
+ * specified {@code GraphicsConfiguration} of a screen device.
* <p>
* This constructor sets the component's locale property to the value
- * returned by <code>JComponent.getDefaultLocale</code>.
+ * returned by {@code JComponent.getDefaultLocale}.
*
* @param title the title to be displayed in the
- * frame's border. A <code>null</code> value is treated as
+ * frame's border. A {@code null} value is treated as
* an empty string, "".
- * @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
+ * @param gc the {@code GraphicsConfiguration} that is used
+ * to construct the new {@code JFrame} with;
+ * if {@code gc} is {@code null}, the system
+ * default {@code GraphicsConfiguration} is assumed
+ * @exception IllegalArgumentException if {@code gc} is not from
* a screen device. This exception is always thrown when
* GraphicsEnvironment.isHeadless() returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
* @see JComponent#getDefaultLocale
* @since 1.3
@@ -250,11 +250,11 @@
public JFrame(String title, GraphicsConfiguration gc) {
super(title, gc);
frameInit();
}
- /** Called by the constructors to init the <code>JFrame</code> properly. */
+ /** Called by the constructors to init the {@code JFrame} properly. */
protected void frameInit() {
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
setLocale( JComponent.getDefaultLocale() );
setRootPane(createRootPane());
setBackground(UIManager.getColor("control"));
@@ -270,11 +270,11 @@
sun.awt.SunToolkit.checkAndSetPolicy(this);
}
/**
* Called by the constructor methods to create the default
- * <code>rootPane</code>.
+ * {@code rootPane}.
*
* @return a new {@code JRootPane}
*/
protected JRootPane createRootPane() {
JRootPane rp = new JRootPane();
@@ -287,11 +287,11 @@
}
/**
* 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.
+ * of the {@code defaultCloseOperation} property.
*
* @param e the window event
* @see #setDefaultCloseOperation
* @see java.awt.Window#processWindowEvent
*/
@@ -321,35 +321,35 @@
* 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:
* <br><br>
* <ul>
- * <li><code>DO_NOTHING_ON_CLOSE</code>
- * (defined in <code>WindowConstants</code>):
+ * <li>{@code DO_NOTHING_ON_CLOSE}
+ * (defined in {@code WindowConstants}):
* Don't do anything; require the
- * program to handle the operation in the <code>windowClosing</code>
- * method of a registered <code>WindowListener</code> object.
+ * program to handle the operation in the {@code windowClosing}
+ * method of a registered {@code WindowListener} object.
*
- * <li><code>HIDE_ON_CLOSE</code>
- * (defined in <code>WindowConstants</code>):
+ * <li>{@code HIDE_ON_CLOSE}
+ * (defined in {@code WindowConstants}):
* Automatically hide the frame after
- * invoking any registered <code>WindowListener</code>
+ * invoking any registered {@code WindowListener}
* objects.
*
- * <li><code>DISPOSE_ON_CLOSE</code>
- * (defined in <code>WindowConstants</code>):
+ * <li>{@code DISPOSE_ON_CLOSE}
+ * (defined in {@code WindowConstants}):
* Automatically hide and dispose the
- * frame after invoking any registered <code>WindowListener</code>
+ * frame after invoking any registered {@code WindowListener}
* objects.
*
- * <li><code>EXIT_ON_CLOSE</code>
- * (defined in <code>WindowConstants</code>):
- * Exit the application using the <code>System</code>
- * <code>exit</code> method. Use this only in applications.
+ * <li>{@code EXIT_ON_CLOSE}
+ * (defined in {@code WindowConstants}):
+ * Exit the application using the {@code System}
+ * {@code exit} method. Use this only in applications.
* </ul>
* <p>
- * The value is set to <code>HIDE_ON_CLOSE</code> by default. Changes
+ * The value is set to {@code HIDE_ON_CLOSE} by default. Changes
* to the value of this property cause the firing of a property
* change event, with property name "defaultCloseOperation".
* <p>
* <b>Note</b>: When the last displayable window within the
* Java virtual machine (VM) is disposed of, the VM may
@@ -362,13 +362,13 @@
* isn't one of the above valid values
* @see #addWindowListener
* @see #getDefaultCloseOperation
* @see WindowConstants
* @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>
+ * if {@code EXIT_ON_CLOSE} has been specified and the
+ * {@code SecurityManager} will
+ * not allow the caller to invoke {@code System.exit}
* @see java.lang.Runtime#exit(int)
*
* @beaninfo
* preferred: true
* bound: true
@@ -452,24 +452,24 @@
SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
firePropertyChange("transferHandler", oldHandler, newHandler);
}
/**
- * Gets the <code>transferHandler</code> property.
+ * Gets the {@code transferHandler} property.
*
- * @return the value of the <code>transferHandler</code> property
+ * @return the value of the {@code transferHandler} property
*
* @see TransferHandler
* @see #setTransferHandler
* @since 1.6
*/
public TransferHandler getTransferHandler() {
return transferHandler;
}
/**
- * Just calls <code>paint(g)</code>. This method was overridden to
+ * Just calls {@code paint(g)}. This method was overridden to
* prevent an unnecessary call to clear the background.
*
* @param g the Graphics context in which to paint
*/
public void update(Graphics g) {
@@ -499,14 +499,14 @@
public JMenuBar getJMenuBar() {
return getRootPane().getJMenuBar();
}
/**
- * Returns whether calls to <code>add</code> and
- * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
+ * Returns whether calls to {@code add} and
+ * {@code setLayout} are forwarded to the {@code contentPane}.
*
- * @return true if <code>add</code> and <code>setLayout</code>
+ * @return true if {@code add} and {@code setLayout}
* are forwarded; false otherwise
*
* @see #addImpl
* @see #setLayout
* @see #setRootPaneCheckingEnabled
@@ -516,16 +516,16 @@
return rootPaneCheckingEnabled;
}
/**
- * Sets whether calls to <code>add</code> and
- * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
+ * Sets whether calls to {@code add} and
+ * {@code setLayout} are forwarded to the {@code contentPane}.
*
- * @param enabled true if <code>add</code> and <code>setLayout</code>
+ * @param enabled true if {@code add} and {@code setLayout}
* are forwarded, false if they should operate directly on the
- * <code>JFrame</code>.
+ * {@code JFrame}.
*
* @see #addImpl
* @see #setLayout
* @see #isRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
@@ -537,21 +537,21 @@
rootPaneCheckingEnabled = enabled;
}
/**
- * Adds the specified child <code>Component</code>.
+ * Adds the specified child {@code Component}.
* This method is overridden to conditionally forward calls to the
- * <code>contentPane</code>.
- * By default, children are added to the <code>contentPane</code> instead
+ * {@code contentPane}.
+ * By default, children are added to the {@code contentPane} instead
* of the frame, refer to {@link javax.swing.RootPaneContainer} for
* details.
*
* @param comp the component to be enhanced
* @param constraints the constraints to be respected
* @param index the index
- * @exception IllegalArgumentException if <code>index</code> is invalid
+ * @exception IllegalArgumentException if {@code index} is invalid
* @exception IllegalArgumentException if adding the container's parent
* to itself
* @exception IllegalArgumentException if adding a window to a container
*
* @see #setRootPaneCheckingEnabled
@@ -567,17 +567,17 @@
}
}
/**
* 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>.
+ * {@code comp} is not the {@code rootPane}, this will forward
+ * the call to the {@code contentPane}. This will do nothing if
+ * {@code comp} is not a child of the {@code JFrame} or
+ * {@code contentPane}.
*
* @param comp the component to be removed
- * @throws NullPointerException if <code>comp</code> is null
+ * @throws NullPointerException if {@code comp} is null
* @see #add
* @see javax.swing.RootPaneContainer
*/
public void remove(Component comp) {
if (comp == rootPane) {
@@ -587,17 +587,17 @@
}
}
/**
- * Sets the <code>LayoutManager</code>.
+ * Sets the {@code LayoutManager}.
* Overridden to conditionally forward the call to the
- * <code>contentPane</code>.
+ * {@code contentPane}.
* Refer to {@link javax.swing.RootPaneContainer} for
* more information.
*
- * @param manager the <code>LayoutManager</code>
+ * @param manager the {@code LayoutManager}
* @see #setRootPaneCheckingEnabled
* @see javax.swing.RootPaneContainer
*/
public void setLayout(LayoutManager manager) {
if(isRootPaneCheckingEnabled()) {
@@ -608,25 +608,25 @@
}
}
/**
- * Returns the <code>rootPane</code> object for this frame.
- * @return the <code>rootPane</code> property
+ * Returns the {@code rootPane} object for this frame.
+ * @return the {@code rootPane} property
*
* @see #setRootPane
* @see RootPaneContainer#getRootPane
*/
public JRootPane getRootPane() {
return rootPane;
}
/**
- * Sets the <code>rootPane</code> property.
+ * Sets the {@code rootPane} property.
* This method is called by the constructor.
- * @param root the <code>rootPane</code> object for this frame
+ * @param root the {@code rootPane} object for this frame
*
* @see #getRootPane
*
* @beaninfo
* hidden: true
@@ -656,33 +656,33 @@
public void setIconImage(Image image) {
super.setIconImage(image);
}
/**
- * Returns the <code>contentPane</code> object for this frame.
- * @return the <code>contentPane</code> property
+ * Returns the {@code contentPane} object for this frame.
+ * @return the {@code contentPane} property
*
* @see #setContentPane
* @see RootPaneContainer#getContentPane
*/
public Container getContentPane() {
return getRootPane().getContentPane();
}
/**
- * Sets the <code>contentPane</code> property.
+ * Sets the {@code contentPane} property.
* This method is called by the constructor.
* <p>
- * Swing's painting architecture requires an opaque <code>JComponent</code>
+ * Swing's painting architecture requires an opaque {@code JComponent}
* in the containment hierarchy. 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>.
+ * replace it with an opaque {@code JComponent}.
*
- * @param contentPane the <code>contentPane</code> object for this frame
+ * @param contentPane the {@code contentPane} object for this frame
*
* @exception java.awt.IllegalComponentStateException (a runtime
- * exception) if the content pane parameter is <code>null</code>
+ * exception) if the content pane parameter is {@code null}
* @see #getContentPane
* @see RootPaneContainer#setContentPane
* @see JRootPane
*
* @beaninfo
@@ -693,27 +693,27 @@
public void setContentPane(Container contentPane) {
getRootPane().setContentPane(contentPane);
}
/**
- * Returns the <code>layeredPane</code> object for this frame.
- * @return the <code>layeredPane</code> property
+ * Returns the {@code layeredPane} object for this frame.
+ * @return the {@code layeredPane} property
*
* @see #setLayeredPane
* @see RootPaneContainer#getLayeredPane
*/
public JLayeredPane getLayeredPane() {
return getRootPane().getLayeredPane();
}
/**
- * Sets the <code>layeredPane</code> property.
+ * Sets the {@code layeredPane} property.
* This method is called by the constructor.
- * @param layeredPane the <code>layeredPane</code> object for this frame
+ * @param layeredPane the {@code layeredPane} object for this frame
*
* @exception java.awt.IllegalComponentStateException (a runtime
- * exception) if the layered pane parameter is <code>null</code>
+ * exception) if the layered pane parameter is {@code null}
* @see #getLayeredPane
* @see RootPaneContainer#setLayeredPane
*
* @beaninfo
* hidden: true
@@ -722,24 +722,24 @@
public void setLayeredPane(JLayeredPane layeredPane) {
getRootPane().setLayeredPane(layeredPane);
}
/**
- * Returns the <code>glassPane</code> object for this frame.
- * @return the <code>glassPane</code> property
+ * Returns the {@code glassPane} object for this frame.
+ * @return the {@code glassPane} property
*
* @see #setGlassPane
* @see RootPaneContainer#getGlassPane
*/
public Component getGlassPane() {
return getRootPane().getGlassPane();
}
/**
- * Sets the <code>glassPane</code> property.
+ * Sets the {@code glassPane} property.
* This method is called by the constructor.
- * @param glassPane the <code>glassPane</code> object for this frame
+ * @param glassPane the {@code glassPane} object for this frame
*
* @see #getGlassPane
* @see RootPaneContainer#setGlassPane
*
* @beaninfo
@@ -760,11 +760,11 @@
return super.getGraphics();
}
/**
* Repaints the specified rectangle of this component within
- * <code>time</code> milliseconds. Refer to <code>RepaintManager</code>
+ * {@code time} milliseconds. Refer to {@code RepaintManager}
* 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
@@ -782,19 +782,19 @@
super.repaint(time, x, y, width, height);
}
}
/**
- * Provides a hint as to whether or not newly created <code>JFrame</code>s
+ * Provides a hint as to whether or not newly created {@code JFrame}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
+ * and feel. If {@code defaultLookAndFeelDecorated} is true,
+ * the current {@code LookAndFeel} 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
+ * windows, then newly created {@code JFrame}s will have their
+ * Window decorations provided by the current {@code LookAndFeel}.
+ * Otherwise, newly created {@code JFrame}s will have their
* Window decorations provided by the current window manager.
* <p>
* You can get the same effect on a single JFrame by doing the following:
* <pre>
* JFrame frame = new JFrame();
@@ -815,11 +815,11 @@
}
}
/**
- * Returns true if newly created <code>JFrame</code>s should have their
+ * Returns true if newly created {@code JFrame}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.
* @since 1.4
@@ -832,18 +832,18 @@
}
return defaultLookAndFeelDecorated.booleanValue();
}
/**
- * Returns a string representation of this <code>JFrame</code>.
+ * Returns a string representation of this {@code JFrame}.
* This method
* 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
- * be <code>null</code>.
+ * be {@code null}.
*
- * @return a string representation of this <code>JFrame</code>
+ * @return a string representation of this {@code JFrame}
*/
protected String paramString() {
String defaultCloseOperationString;
if (defaultCloseOperation == HIDE_ON_CLOSE) {
defaultCloseOperationString = "HIDE_ON_CLOSE";
@@ -892,11 +892,11 @@
return accessibleContext;
}
/**
* This class implements accessibility support for the
- * <code>JFrame</code> class. It provides an implementation of the
+ * {@code JFrame} class. It provides an implementation of the
* Java Accessibility API appropriate to frame user-interface
* elements.
*/
protected class AccessibleJFrame extends AccessibleAWTFrame {
< prev index next >