|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
public class JFrame
A window that supports window decorations (titlebar and borders).
This is an extension of Frame
that provides support
for the Swing architecture. Most importantly it contains a JRootPane
as it's only top-level child, that manages the content pane, the menu and
a glass pane.
Also, unlike java.awt.Frame
s, JFrames support the
Swing Pluggable Look & Feel architecture.
Nested Class Summary | |
---|---|
protected class |
JFrame.AccessibleJFrame
Provides accessibility support for JFrame s. |
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, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected AccessibleContext |
accessibleContext
|
static int |
EXIT_ON_CLOSE
A flag for setDefaultCloseOperation(int) , indicating that the
application should be exited, when this JFrame is closed. |
protected JRootPane |
rootPane
|
protected boolean |
rootPaneCheckingEnabled
|
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JFrame()
Creates a new frame with an empty string for the title. |
|
JFrame(GraphicsConfiguration gc)
Creates a new JFrame in the specified GraphicsConfiguration
and with an empty title. |
|
JFrame(String title)
Creates a new JFrame with the specified title. |
|
JFrame(String title,
GraphicsConfiguration gc)
Creates a new JFrame in the specified GraphicsConfiguration
and with the specified title. |
Method Summary | |
---|---|
protected void |
addImpl(Component comp,
Object constraints,
int index)
This method is called by all the add() methods to perform
the actual adding of the component. |
protected JRootPane |
createRootPane()
|
protected void |
frameInit()
|
AccessibleContext |
getAccessibleContext()
Returns the object that provides accessibility features for this JFrame . |
Container |
getContentPane()
getContentPane |
int |
getDefaultCloseOperation()
Returns a code for the default operation when the frame is closed. |
Component |
getGlassPane()
getGlassPane |
JMenuBar |
getJMenuBar()
|
JLayeredPane |
getLayeredPane()
getLayeredPane |
Dimension |
getPreferredSize()
Returns the preferred size of this container. |
JRootPane |
getRootPane()
getRootPane |
static boolean |
isDefaultLookAndFeelDecorated()
|
protected boolean |
isRootPaneCheckingEnabled()
|
protected String |
paramString()
Returns a string describing the attributes for the JFrame ,
for use in debugging. |
protected void |
processKeyEvent(KeyEvent e)
Called when a key event is dispatched and component events are enabled. |
protected void |
processWindowEvent(WindowEvent e)
Dispatches this event to any listeners that are listening for WindowEvents on this window. |
void |
remove(Component comp)
Removes the specified component from this container. |
void |
setContentPane(Container contentPane)
setContentPane |
void |
setDefaultCloseOperation(int operation)
Sets the default operation that is performed when this frame is closed. |
static void |
setDefaultLookAndFeelDecorated(boolean decorated)
|
void |
setGlassPane(Component glassPane)
setGlassPane |
void |
setJMenuBar(JMenuBar menubar)
|
void |
setLayeredPane(JLayeredPane layeredPane)
setLayeredPane |
void |
setLayout(LayoutManager manager)
Sets the layout manager for this container to the specified layout manager. |
protected void |
setRootPane(JRootPane root)
|
protected void |
setRootPaneCheckingEnabled(boolean enabled)
|
void |
update(Graphics g)
Updates this container. |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Field Detail |
---|
public static final int EXIT_ON_CLOSE
setDefaultCloseOperation(int)
, indicating that the
application should be exited, when this JFrame
is closed.
Note that in version 1.4, the equivalent constant has been added to
WindowConstants
.
protected AccessibleContext accessibleContext
protected JRootPane rootPane
protected boolean rootPaneCheckingEnabled
Constructor Detail |
---|
public JFrame()
public JFrame(String title)
JFrame
with the specified title.
title
- the frame title (null
permitted).public JFrame(GraphicsConfiguration gc)
GraphicsConfiguration
and with an empty title.
gc
- the GraphicsConfiguration
that is used for
the new JFrame
Frame#Frame(GraphicsConfiguration)
public JFrame(String title, GraphicsConfiguration gc)
GraphicsConfiguration
and with the specified title.
title
- the title for the new JFrame
gc
- the GraphicsConfiguration
that is used for
the new JFrame
Frame#Frame(String, GraphicsConfiguration)
Method Detail |
---|
protected void frameInit()
public Dimension getPreferredSize()
Container
getPreferredSize
in class Container
Component.getMinimumSize()
,
Component.setPreferredSize(Dimension)
,
LayoutManager
public JMenuBar getJMenuBar()
public void setJMenuBar(JMenuBar menubar)
public void setLayout(LayoutManager manager)
Container
setLayout
in class Container
manager
- The new layout manager for this container.public void setLayeredPane(JLayeredPane layeredPane)
RootPaneContainer
setLayeredPane
in interface RootPaneContainer
layeredPane
- TODOpublic JLayeredPane getLayeredPane()
RootPaneContainer
getLayeredPane
in interface RootPaneContainer
public JRootPane getRootPane()
RootPaneContainer
getRootPane
in interface RootPaneContainer
protected void setRootPane(JRootPane root)
protected JRootPane createRootPane()
public Container getContentPane()
RootPaneContainer
getContentPane
in interface RootPaneContainer
public void setContentPane(Container contentPane)
RootPaneContainer
setContentPane
in interface RootPaneContainer
contentPane
- TODOpublic Component getGlassPane()
RootPaneContainer
getGlassPane
in interface RootPaneContainer
public void setGlassPane(Component glassPane)
RootPaneContainer
setGlassPane
in interface RootPaneContainer
glassPane
- TODOprotected void addImpl(Component comp, Object constraints, int index)
Container
add()
methods to perform
the actual adding of the component. Subclasses who wish to perform
their own processing when a component is added should override this
method. Any subclass doing this must call the superclass version of
this method in order to ensure proper functioning of the container.
addImpl
in class Container
comp
- The component to be added.constraints
- The layout constraints for this component, or
null
if there are no constraints.index
- The index in the component list to insert this child
at, or -1 to add at the end of the list.public void remove(Component comp)
Container
remove
in class Container
comp
- The component to remove from this container.protected boolean isRootPaneCheckingEnabled()
protected void setRootPaneCheckingEnabled(boolean enabled)
public void update(Graphics g)
Container
update
in class Container
g
- The graphics context for this update.Component.paint(Graphics)
,
Component.repaint()
protected void processKeyEvent(KeyEvent e)
Component
processKeyEvent
in class Component
e
- the KeyEvent
to processKeyListener
,
Component.addKeyListener(KeyListener)
,
Component.enableEvents(long)
public static void setDefaultLookAndFeelDecorated(boolean decorated)
public static boolean isDefaultLookAndFeelDecorated()
public AccessibleContext getAccessibleContext()
JFrame
.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class Frame
JFrame.AccessibleJFrame
).public int getDefaultCloseOperation()
WindowConstants.HIDE_ON_CLOSE
.
WindowConstants.DO_NOTHING_ON_CLOSE
,
WindowConstants.HIDE_ON_CLOSE
,
WindowConstants.DISPOSE_ON_CLOSE
, EXIT_ON_CLOSE
.setDefaultCloseOperation(int)
protected String paramString()
JFrame
,
for use in debugging. The return value is guaranteed to be
non-null
, but the format may vary between implementations.
paramString
in class Frame
JFrame
.protected void processWindowEvent(WindowEvent e)
Window
WindowEvents
on this window. This method only gets
invoked if it is enabled via enableEvents()
or if
a listener has been added.
processWindowEvent
in class Window
e
- The event to process.public void setDefaultCloseOperation(int operation)
HIDE_ON_CLOSE
. When
EXIT_ON_CLOSE
is specified this method calls
SecurityManager.checkExit(0)
which might throw a
SecurityException
.
operation
- a code for the operation (one of:
WindowConstants.DO_NOTHING_ON_CLOSE
,
WindowConstants.HIDE_ON_CLOSE
,
WindowConstants.DISPOSE_ON_CLOSE
and
WindowConstants.EXIT_ON_CLOSE
).
IllegalArgumentException
- if operation
is not one of
the specified codes.getDefaultCloseOperation()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |