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
WindowEvent
s:
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
Modifier and Type | Class and Description |
---|---|
protected class | Frame.
This class implements accessibility support for the
|
Modifier and Type | Field and Description |
---|---|
private static final String | base
Hides java. |
public static final int | CROSSHAIR_CURSOR
Deprecated
replaced by
Cursor.CROSSHAIR_CURSOR .
|
public static final int | DEFAULT_CURSOR
Deprecated
replaced by
Cursor.DEFAULT_CURSOR .
|
public static final int | E_RESIZE_CURSOR
Deprecated
replaced by
Cursor.E_RESIZE_CURSOR .
|
private int | frameSerializedDataVersion
|
public static final int | HAND_CURSOR
Deprecated
replaced by
Cursor.HAND_CURSOR .
|
public static final int | ICONIFIED
This state bit indicates that frame is iconified. |
public static final int | MAXIMIZED_BOTH
This state bit mask indicates that frame is fully maximized (that is both horizontally and vertically). |
public static final int | MAXIMIZED_HORIZ
This state bit indicates that frame is maximized in the horizontal direction. |
public static final int | MAXIMIZED_VERT
This state bit indicates that frame is maximized in the vertical direction. |
pack-priv Rectangle | maximizedBounds
Maximized bounds for this frame. |
pack-priv boolean | mbManagement
|
pack-priv MenuBar | menuBar
The frames menubar. |
public static final int | MOVE_CURSOR
Deprecated
replaced by
Cursor.MOVE_CURSOR .
|
public static final int | N_RESIZE_CURSOR
Deprecated
replaced by
Cursor.N_RESIZE_CURSOR .
|
private static int | |
public static final int | NE_RESIZE_CURSOR
Deprecated
replaced by
Cursor.NE_RESIZE_CURSOR .
|
public static final int | NORMAL
Frame is in the "normal" state. |
public static final int | NW_RESIZE_CURSOR
Deprecated
replaced by
Cursor.NW_RESIZE_CURSOR .
|
pack-priv Vector | ownedWindows
The Windows owned by the Frame. |
pack-priv boolean | resizable
This field indicates whether the frame is resizable. |
public static final int | S_RESIZE_CURSOR
Deprecated
replaced by
Cursor.S_RESIZE_CURSOR .
|
public static final int | SE_RESIZE_CURSOR
Deprecated
replaced by
Cursor.SE_RESIZE_CURSOR .
|
private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
private int | state
Hides java. |
public static final int | SW_RESIZE_CURSOR
Deprecated
replaced by
Cursor.SW_RESIZE_CURSOR .
|
public static final int | TEXT_CURSOR
Deprecated
replaced by
Cursor.TEXT_CURSOR .
|
pack-priv String | title
This is the title of the frame. |
pack-priv boolean | undecorated
This field indicates whether the frame is undecorated. |
public static final int | W_RESIZE_CURSOR
Deprecated
replaced by
Cursor.W_RESIZE_CURSOR .
|
public static final int | WAIT_CURSOR
Deprecated
replaced by
Cursor.WAIT_CURSOR .
|
Access | Constructor and Description |
---|---|
public | |
public | Frame(GraphicsConfiguration
the gc)GraphicsConfiguration
of the target screen device. If gc
is null , the system default
GraphicsConfiguration is assumed.Constructs a new, initially invisible |
public | |
public | Frame(String
the title to be displayed in the frame's border.
A title, GraphicsConfiguration null value
is treated as an empty string, "".the gc)GraphicsConfiguration
of the target screen device. If gc is
null , the system default
GraphicsConfiguration is assumed.Constructs a new, initially invisible |
Modifier and Type | Method and Description |
---|---|
public void | addNotify()
Overrides java. |
pack-priv String | constructComponentName()
Overrides java. |
public AccessibleContext | Returns: an AccessibleAWTFrame that serves as the AccessibleContext of this FrameOverrides java. Implements javax. |
public int | Returns: the cursor type for this frame
Deprecated
As of JDK version 1.1,
replaced by
Component.getCursor() .
|
public int | |
public static Frame[] | Returns: the array of allFrame s created by this applicationReturns an array of all |
public Image | Returns: the icon image for this frame, ornull
if this frame doesn't have an icon image.Returns the image to be displayed as the icon for this frame. |
public Rectangle | Returns: maximized bounds for this frame; may benull Gets maximized bounds for this frame. |
public MenuBar | Returns: the menu bar for this frame, ornull
if this frame doesn't have a menu bar.Gets the menu bar for this frame. |
public synchronized int | |
public String | Returns: the title of this frame, or an empty string ("") if this frame doesn't have a title.Gets the title of the frame. |
private void | |
private static native void | |
private boolean | |
public boolean | Returns: true if the user can resize this frame;
false otherwise.Indicates whether this frame is resizable by the user. |
public boolean | Returns: true if frame is undecorated;
false otherwise.Indicates whether this frame is undecorated. |
protected String | Returns: the parameter string of this frameOverrides java. Frame .
|
pack-priv void | |
private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. ObjectInputStream .
|
public void | remove(MenuComponent
the menu component to remove.
If m)m is null , then
no action is takenOverrides java. Implements java. |
public void | removeNotify()
Overrides java. |
public void | setBackground(Color
the color to become this window's background color. bgColor)Overrides java. |
public void | setCursor(int
the cursor type cursorType)
Deprecated
As of JDK version 1.1,
replaced by
Sets the cursor for this frame to the specified type.
Component.setCursor(Cursor) .
|
public void | |
public void | setIconImage(Image
the icon image to be displayed. image)Overrides java. |
public void | setMaximizedBounds(Rectangle
bounds for the maximized state bounds)Sets the maximized bounds for this frame. |
public void | setMenuBar(MenuBar
the menu bar being set.
If this parameter is mb)null then any
existing menu bar on this frame is removed.Sets the menu bar for this frame to the specified menu bar. |
public void | setOpacity(float
the opacity level to set to the window opacity)Overrides java. |
public void | setResizable(boolean
true if this frame is resizable;
false otherwise.Sets whether this frame is resizable by the user. |
public void | setShape(Shape
the shape to set to the window shape)Overrides java. |
public synchronized void | |
public void | |
public void | setUndecorated(boolean
true if no frame decorations are to be
enabled; false if frame decorations are to be enabledDisables or enables decorations for this frame. |
private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to writeHides java. |