|
||||||||||
| 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
, MenuContainer
, Serializable
, Accessible


public class Frame


A Frame is a top-level window with a title and a border.
The size of the frame includes any area designated for the
border. The dimensions of the border area may be obtained
using the getInsets method, however, since
these dimensions are platform-dependent, a valid insets
value cannot be obtained until the frame is made displayable
by either calling pack or show.
Since the border area is included in the overall size of the
frame, the border effectively obscures a portion of the frame,
constraining the area available for rendering and/or displaying
subcomponents to the rectangle which has an upper-left corner
location of (insets.left, insets.top), and has a size of
width - (insets.left + insets.right) by
height - (insets.top + insets.bottom).
The default layout for a frame is BorderLayout.
A frame may have its native decorations (i.e. Frame
and Titlebar) turned off
with setUndecorated. This can only be done while the frame
is not displayable
.
In a multi-screen environment, you can create a Frame
on a different screen device by constructing the Frame
with Frame(GraphicsConfiguration)
or
Frame(String title, GraphicsConfiguration)
. The
GraphicsConfiguration object is one of the
GraphicsConfiguration objects of the target screen
device.
In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of all configurations are relative to the virtual-coordinate system. The origin of the virtual-coordinate system is at the upper left-hand corner of the primary physical screen. Depending on the location of the primary screen in the virtual device, negative coordinates are possible, as shown in the following figure.
In such an environment, when calling setLocation,
you must pass a virtual coordinate to this method. Similarly,
calling getLocationOnScreen on a Frame
returns virtual device coordinates. Call the getBounds
method of a GraphicsConfiguration to find its origin in
the virtual coordinate system.
The following code sets the
location of the Frame at (10, 10) relative
to the origin of the physical screen of the corresponding
GraphicsConfiguration. If the bounds of the
GraphicsConfiguration is not taken into account, the
Frame location would be set at (10, 10) relative to the
virtual-coordinate system and would appear on the primary physical
screen, which might be different from the physical screen of the
specified GraphicsConfiguration.
Frame f = new Frame(GraphicsConfiguration gc);
Rectangle bounds = gc.getBounds();
f.setLocation(10 + bounds.x, 10 + bounds.y);
Frames are capable of generating the following types of
WindowEvents:
WINDOW_OPENED
WINDOW_CLOSING:
WINDOW_CLOSED
WINDOW_ICONIFIED
WINDOW_DEICONIFIED
WINDOW_ACTIVATED
WINDOW_DEACTIVATED
WINDOW_GAINED_FOCUS
WINDOW_LOST_FOCUS
WINDOW_STATE_CHANGED
WindowEvent
,
Window.addWindowListener(java.awt.event.WindowListener)
,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
Frame.AccessibleAWTFrame
This class implements accessibility support for the Frame class. |
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 | |
|---|---|
static int |
CROSSHAIR_CURSOR
Deprecated. replaced by Cursor.CROSSHAIR_CURSOR. |
static int |
DEFAULT_CURSOR
Deprecated. replaced by Cursor.DEFAULT_CURSOR. |
static int |
E_RESIZE_CURSOR
Deprecated. replaced by Cursor.E_RESIZE_CURSOR. |
static int |
HAND_CURSOR
Deprecated. replaced by Cursor.HAND_CURSOR. |
static int |
ICONIFIED
This state bit indicates that frame is iconified. |
static int |
MAXIMIZED_BOTH
This state bit mask indicates that frame is fully maximized (that is both horizontally and vertically). |
static int |
MAXIMIZED_HORIZ
This state bit indicates that frame is maximized in the horizontal direction. |
static int |
MAXIMIZED_VERT
This state bit indicates that frame is maximized in the vertical direction. |
static int |
MOVE_CURSOR
Deprecated. replaced by Cursor.MOVE_CURSOR. |
static int |
N_RESIZE_CURSOR
Deprecated. replaced by Cursor.N_RESIZE_CURSOR. |
static int |
NE_RESIZE_CURSOR
Deprecated. replaced by Cursor.NE_RESIZE_CURSOR. |
static int |
NORMAL
Frame is in the "normal" state. |
static int |
NW_RESIZE_CURSOR
Deprecated. replaced by Cursor.NW_RESIZE_CURSOR. |
static int |
S_RESIZE_CURSOR
Deprecated. replaced by Cursor.S_RESIZE_CURSOR. |
static int |
SE_RESIZE_CURSOR
Deprecated. replaced by Cursor.SE_RESIZE_CURSOR. |
static int |
SW_RESIZE_CURSOR
Deprecated. replaced by Cursor.SW_RESIZE_CURSOR. |
static int |
TEXT_CURSOR
Deprecated. replaced by Cursor.TEXT_CURSOR. |
static int |
W_RESIZE_CURSOR
Deprecated. replaced by Cursor.W_RESIZE_CURSOR. |
static int |
WAIT_CURSOR
Deprecated. replaced by Cursor.WAIT_CURSOR. |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
Frame
Constructs a new instance of Frame that is
initially invisible. |
|
Frame
Create a Frame with the specified
GraphicsConfiguration of
a screen device. |
|
Frame
Constructs a new, initially invisible Frame object
with the specified title. |
|
Frame
Constructs a new, initially invisible Frame object
with the specified title and a
GraphicsConfiguration. |
|
| Method Summary | |
|---|---|
void |
addNotify
Makes this Frame displayable by connecting it to a native screen resource. |
protected void |
finalize
Disposes of the input methods and context, and removes this Frame from the AppContext. |
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this Frame. |
int |
getCursorType
Deprecated. As of JDK version 1.1, replaced by Component.getCursor(). |
int |
getExtendedState
Gets the state of this frame. |
static Frame |
getFrames
Returns an array containing all Frames created by the application. |
Image |
getIconImage
Gets the image to be displayed in the minimized icon for this frame. |
Rectangle |
getMaximizedBounds
Gets maximized bounds for this frame. |
MenuBar |
getMenuBar
Gets the menu bar for this frame. |
int |
getState
Gets the state of this frame (obsolete). |
String |
getTitle
Gets the title of the frame. |
boolean |
isResizable
Indicates whether this frame is resizable by the user. |
boolean |
isUndecorated
Indicates whether this frame is undecorated. |
protected String |
paramString
Returns a string representing the state of this Frame. |
void |
remove
Removes the specified menu bar from this frame. |
void |
removeNotify
Makes this Frame undisplayable by removing its connection to its native screen resource. |
void |
setCursor
Deprecated. As of JDK version 1.1, replaced by Component.setCursor(Cursor). |
void |
setExtendedState
Sets the state of this frame. |
void |
setIconImage
Sets the image to be displayed in the minimized icon for this frame. |
void |
setMaximizedBounds
Sets the maximized bounds for this frame. |
void |
setMenuBar
Sets the menu bar for this frame to the specified menu bar. |
void |
setResizable
Sets whether this frame is resizable by the user. |
void |
setState
Sets the state of this frame (obsolete). |
void |
setTitle
Sets the title for this frame to the specified string. |
void |
setUndecorated
Disables or enables decorations for this frame. |
Methods inherited from class java.awt.Container ![]() |
|---|
add |