All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.JFrame
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Window
|
+----java.awt.Frame
|
+----com.sun.java.swing.JFrame
- public class JFrame
- extends Frame
- implements WindowConstants, Accessible, RootPaneContainer
An extended version of java.awt.Frame that adds support for
interposing input and painting behavior in front of the frames
children (see glassPane), support for special children that
are managed by a LayeredPane (see rootPane) and for Swing MenuBars.
The JFrame class is slightly incompatible with java.awt.Frame.
JFrame contains a JRootPane as it's only child.
The contentPane should be the parent of any children of the JFrame.
This is different than java.awt.Frame, e.g. to add a child to
an AWT Frame you'd write:
frame.add(child);
However using JFrame you need to add the child to the JFrames contentPane
instead:
frame.getContentPane().add(child);
The same is true for setting LayoutManagers, removing components,
listing children, etc. All these methods should normally be sent to
the contentPane() instead of the JFrame itself. The contentPane() will
always be non-null. Attempting to set it to null will cause the JFrame
to throw an exception. The default contentPane() will have a BorderLayout
manager set on it.
Please see the JRootPane documentation for a complete description of
the contentPane, glassPane, and layeredPane properties.
For the keyboard keys used by this component in the standard Look and
Feel (L&F) renditions, see the
JFrame key assignments.
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 Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
- See Also:
- JRootPane
-
accessibleContext
- The accessible context property
-
rootPane
- The JRootPane instance that manages the
contentPane
and optional menuBar
for this frame, as well as the
glassPane
.
-
rootPaneCheckingEnabled
- If true then calls to
add
and setLayout
cause an exception to be thrown.
-
JFrame()
- Constructs a new Frame that is initially invisible.
-
JFrame(String)
- Constructs a new, initially invisible Frame with the specified
title.
-
addImpl(Component, Object, int)
- By default, children may not be added directly to a this component,
they must be added to its contentPane instead.
-
createRootPane()
- Called by the constructor methods to create the default rootPane.
-
frameInit()
- Called by the constructors to init the JFrame properly.
-
getAccessibleContext()
- Get the AccessibleContext associated with this JFrame
-
getContentPane()
- Returns the contentPane object for this frame.
-
getDefaultCloseOperation()
- Returns the operation which occurs when the user
initiates a "close" on this frame.
-
getGlassPane()
- Returns the glassPane object for this frame.
-
getJMenuBar()
- Returns the menubar set on this frame.
-
getLayeredPane()
- Returns the layeredPane object for this frame.
-
getRootPane()
- Returns the rootPane object for this frame.
-
isRootPaneCheckingEnabled()
- Returns whether calls to
add
and
setLayout
cause an exception to be thrown.
-
processKeyEvent(KeyEvent)
-
Processes key events occurring on this component and, if appropriate,
passes them on to components in the frame which have registered
interest in them.
-
processWindowEvent(WindowEvent)
-
Processes window events occurring on this component.
-
setContentPane(Container)
- Sets the contentPane property.
-
setDefaultCloseOperation(int)
- Sets the operation which will happen by default when
the user initiates a "close" on this frame.
-
setGlassPane(Component)
- Sets the glassPane property.
-
setJMenuBar(JMenuBar)
- Sets the menubar for this frame.
-
setLayeredPane(JLayeredPane)
- Sets the layeredPane property.
-
setLayout(LayoutManager)
- By default the layout of this component may not be set,
the layout of its contentPane should be set instead.
-
setRootPane(JRootPane)
- Sets the rootPane property.
-
setRootPaneCheckingEnabled(boolean)
- Determines whether calls to
add
and
setLayout
cause an exception to be thrown.
-
update(Graphics)
-
Just calls
paint(g)
.
rootPane
protected JRootPane rootPane
- The JRootPane instance that manages the
contentPane
and optional menuBar
for this frame, as well as the
glassPane
.
- See Also:
- JRootPane, RootPaneContainer
rootPaneCheckingEnabled
protected boolean rootPaneCheckingEnabled
- If true then calls to
add
and setLayout
cause an exception to be thrown.
- See Also:
- isRootPaneCheckingEnabled, setRootPaneCheckingEnabled
accessibleContext
protected AccessibleContext accessibleContext
- The accessible context property
JFrame
public JFrame()
- Constructs a new Frame that is initially invisible.
- See Also:
- setSize, setVisible
JFrame
public JFrame(String title)
- Constructs a new, initially invisible Frame with the specified
title.
- Parameters:
- title - the title for the frame
- See Also:
- setSize, setVisible
frameInit
protected void frameInit()
- Called by the constructors to init the JFrame properly.
createRootPane
protected JRootPane createRootPane()
- Called by the constructor methods to create the default rootPane.
processKeyEvent
protected void processKeyEvent(KeyEvent e)
- Processes key events occurring on this component and, if appropriate,
passes them on to components in the frame which have registered
interest in them.
- Parameters:
- e - the key event
- Overrides:
- processKeyEvent in class Component
- See Also:
- processKeyEvent
processWindowEvent
protected void processWindowEvent(WindowEvent e)
- Processes window events occurring on this component.
Hides the window or disposes of it, as specified by the setting
of the
defaultCloseOperation
property.
- Parameters:
- e - the window event
- Overrides:
- processWindowEvent in class Window
- See Also:
- setDefaultCloseOperation, processWindowEvent
setDefaultCloseOperation
public void setDefaultCloseOperation(int operation)
- Sets the operation which will happen by default when
the user initiates a "close" on this frame.
The possible choices are:
- DO_NOTHING_ON_CLOSE - do not do anything - require the
program to handle the operation in the windowClosing
method of a registered WindowListener object.
- HIDE_ON_CLOSE - automatically hide the frame after
invoking any registered WindowListener objects
- DISPOSE_ON_CLOSE - automatically hide and dispose the
frame after invoking any registered WindowListener objects
The value is set to HIDE_ON_CLOSE by default.
- See Also:
- addWindowListener, getDefaultCloseOperation
getDefaultCloseOperation
public int getDefaultCloseOperation()
- Returns the operation which occurs when the user
initiates a "close" on this frame.
- Returns:
- an int indicating the window-close operation
- See Also:
- setDefaultCloseOperation
update
public void update(Graphics g)
- Just calls
paint(g)
. This method was overridden to
prevent an unneccessary call to clear the background.
- Parameters:
- g - the Graphics context in which to paint
- Overrides:
- update in class Container
setJMenuBar
public void setJMenuBar(JMenuBar menubar)
- Sets the menubar for this frame.
- Parameters:
- menubar - the menubar being placed in the frame
- See Also:
- getJMenuBar
getJMenuBar
public JMenuBar getJMenuBar()
- Returns the menubar set on this frame.
- See Also:
- setJMenuBar
isRootPaneCheckingEnabled
protected boolean isRootPaneCheckingEnabled()
- Returns whether calls to
add
and
setLayout
cause an exception to be thrown.
- Returns:
- true if
add
and setLayout
are checked
- See Also:
- addImpl, setLayout, setRootPaneCheckingEnabled
setRootPaneCheckingEnabled
protected void setRootPaneCheckingEnabled(boolean enabled)
- Determines whether calls to
add
and
setLayout
cause an exception to be thrown.
- Parameters:
- enabled - a boolean value, true if checking is to be
enabled, which cause the exceptions to be thrown
- See Also:
- addImpl, setLayout, isRootPaneCheckingEnabled
addImpl
protected void addImpl(Component comp,
Object constraints,
int index)
- By default, children may not be added directly to a this component,
they must be added to its contentPane instead. For example:
thisComponent.getContentPane().add(child)
An attempt to add to directly to this component will cause an
runtime exception to be thrown. Subclasses can disable this
behavior.
- Throws: Error
- if called with rootPaneChecking true
- Overrides:
- addImpl in class Container
- See Also:
- setRootPaneCheckingEnabled
setLayout
public void setLayout(LayoutManager manager)
- By default the layout of this component may not be set,
the layout of its contentPane should be set instead.
For example:
thiComponent.getContentPane().setLayout(new BorderLayout())
An attempt to set the layout of this component will cause an
runtime exception to be thrown. Subclasses can disable this
behavior.
- Throws: Error
- if called with rootPaneChecking true
- Overrides:
- setLayout in class Container
- See Also:
- setRootPaneCheckingEnabled
getRootPane
public JRootPane getRootPane()
- Returns the rootPane object for this frame.
- See Also:
- setRootPane, getRootPane
setRootPane
protected void setRootPane(JRootPane root)
- Sets the rootPane property. This method is called by the constructor.
- Parameters:
- root - the rootPane object for this frame
- See Also:
- getRootPane
getContentPane
public Container getContentPane()
- Returns the contentPane object for this frame.
- See Also:
- setContentPane, getContentPane
setContentPane
public void setContentPane(Container contentPane)
- Sets the contentPane property. This method is called by the constructor.
- Parameters:
- contentPane - the contentPane object for this frame
- Throws: IllegalComponentStateException
- (a runtime
exception) if the content pane parameter is null
- See Also:
- getContentPane, setContentPane
getLayeredPane
public JLayeredPane getLayeredPane()
- Returns the layeredPane object for this frame.
- See Also:
- setLayeredPane, getLayeredPane
setLayeredPane
public void setLayeredPane(JLayeredPane layeredPane)
- Sets the layeredPane property. This method is called by the constructor.
- Parameters:
- layeredPane - the layeredPane object for this frame
- Throws: IllegalComponentStateException
- (a runtime
exception) if the layered pane parameter is null
- See Also:
- getLayeredPane, setLayeredPane
getGlassPane
public Component getGlassPane()
- Returns the glassPane object for this frame.
- See Also:
- setGlassPane, getGlassPane
setGlassPane
public void setGlassPane(Component glassPane)
- Sets the glassPane property.
This method is called by the constructor.
- Parameters:
- glassPane - the glassPane object for this frame
- See Also:
- getGlassPane, setGlassPane
getAccessibleContext
public AccessibleContext getAccessibleContext()
- Get the AccessibleContext associated with this JFrame
- Returns:
- the AccessibleContext of this JFrame
All Packages Class Hierarchy This Package Previous Next Index