|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
java.awt.Window
![]()
![]()
![]()
java.awt.Frame
![]()
![]()
![]()
javax.swing.JFrame
, MenuContainer
, Serializable
, Accessible
, RootPaneContainer
, WindowConstants

public class JFrame

, Accessible
, RootPaneContainer

An extended version of java.awt.Frame that adds support for
the JFC/Swing component architecture.
You can find task-oriented documentation about using JFrame
in The Java Tutorial, in the section
How to Make Frames.
The JFrame class is slightly incompatible with Frame.
Like all other JFC/Swing top-level containers,
a JFrame contains a JRootPane as its only child.
The content pane provided by the root pane should,
as a rule, contain
all the non-menu components displayed by the JFrame.
This is different from the AWT Frame case.
As a conveniance add and its variants, remove and
setLayout have been overridden to forward to the
contentPane as necessary. This means you can write:
frame.add(child);
And the child will be added to the contentPane.
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 RootPaneContainer
for details on adding, removing and setting the LayoutManager
of a JFrame.
Unlike a Frame, a 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
setDefaultCloseOperation(int)
.
To make the JFrame behave the same as a Frame
instance, use
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE).
For more information on content panes and other features that root panes provide, see Using Top-Level Containers in The Java Tutorial.
In a multi-screen environment, you can create a JFrame
on a different screen device. See Frame
for more
information.
Warning:
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 JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
JRootPane
,
setDefaultCloseOperation(int)
,
WindowListener.windowClosing(java.awt.event.WindowEvent)
,
RootPaneContainer
,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
JFrame.AccessibleJFrame
This class implements accessibility support for the JFrame class. |
Nested classes/interfaces inherited from class java.awt.Frame ![]() |
|---|
Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window ![]() |
|---|
Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary | |
|---|---|
protected AccessibleContext |
accessibleContext
The accessible context property. |
static int |
EXIT_ON_CLOSE
The exit application default window close operation. |
protected JRootPane |
rootPane
The JRootPane instance that manages the
contentPane
and optional menuBar for this frame, as well as the
glassPane. |
protected boolean |
rootPaneCheckingEnabled
If true then calls to add and setLayout
will be forwarded to the contentPane. |
Fields inherited from class java.awt.Frame ![]() |
|---|
CROSSHAIR_CURSOR |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants ![]() |
|---|
DISPOSE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JFrame
Constructs a new frame that is initially invisible. |
|
JFrame
Creates a Frame in the specified
GraphicsConfiguration of
a screen device and a blank title. |
|
JFrame
Creates a new, initially invisible Frame with the
specified title. |
|
JFrame
Creates a JFrame with the specified title and the
specified GraphicsConfiguration of a screen device. |
|
| Method Summary | |
|---|---|
protected void |
addImpl
Adds the specified child Component. |
protected JRootPane |
createRootPane
Called by the constructor methods to create the default rootPane. |
protected void |
frameInit
Called by the constructors to init the JFrame properly. |
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this JFrame. |
Container |
getContentPane
Returns the contentPane object for this frame. |
int |
getDefaultCloseOperation
Returns the operation that occurs when the user initiates a "close" on this frame. |
Component |
getGlassPane
Returns the glassPane object for this frame. |
JMenuBar |
getJMenuBar
Returns the menubar set on this frame. |
JLayeredPane |
getLayeredPane
Returns the layeredPane object for this frame. |
JRootPane |
getRootPane
Returns the rootPane object for this frame. |
static boolean |
isDefaultLookAndFeelDecorated
Returns true if newly created JFrames should have their
Window decorations provided by the current look and feel. |
protected boolean |
isRootPaneCheckingEnabled
Returns whether calls to add and
setLayout are forwarded to the contentPane. |
protected String |
paramString
Returns a string representation of this JFrame. |
protected void |
processWindowEvent
Processes window events occurring on this component. |
void |
remove
Removes the specified component from the container. |
void |
setContentPane
Sets the contentPane property. |
void |
setDefaultCloseOperation
Sets the operation that will happen by default when the user initiates a "close" on this frame. |
static void |
setDefaultLookAndFeelDecorated
Provides a hint as to whether or not newly created JFrames
should have their Window decorations (such as borders, widgets to
close the window, title...) provided by the current look
and feel. |
void |
setGlassPane
Sets the glassPane property. |
void |
setIconImage
Sets the image to be displayed in the minimized icon for this frame. |
void |
setJMenuBar
Sets the menubar for this frame. |
void |
setLayeredPane
Sets the layeredPane property. |
void |
setLayout
Sets the LayoutManager. |
protected void |
setRootPane
Sets the rootPane property. |
protected void |
setRootPaneCheckingEnabled
Sets whether calls to add and
setLayout are forwarded to the contentPane. |
void |
update
Just calls paint(g). |
Methods inherited from class java.awt.Frame ![]() |
|---|
addNotify |
Methods inherited from class java.awt.Window ![]() |
|---|
addPropertyChangeListener |