java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
All Implemented Interfaces:
MenuContainer, Accessible, Serializable, ImageObserver
Direct Known Subclasses:
SharedOwnerFrame, DefaultFrame, JFrame
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
Sami - ShaioJDK1.0 - | Nested Class Summary: | ||
|---|---|---|
| protected class | Frame.AccessibleAWTFrame | This class implements accessibility support for the
Frame class. It provides an implementation of the
Java Accessibility API appropriate to frame user-interface elements. |
| Field Summary | ||
|---|---|---|
| public static final int | DEFAULT_CURSOR | |
| public static final int | CROSSHAIR_CURSOR | |
| public static final int | TEXT_CURSOR | |
| public static final int | WAIT_CURSOR | |
| public static final int | SW_RESIZE_CURSOR | |
| public static final int | SE_RESIZE_CURSOR | |
| public static final int | NW_RESIZE_CURSOR | |
| public static final int | NE_RESIZE_CURSOR | |
| public static final int | N_RESIZE_CURSOR | |
| public static final int | S_RESIZE_CURSOR | |
| public static final int | W_RESIZE_CURSOR | |
| public static final int | E_RESIZE_CURSOR | |
| public static final int | HAND_CURSOR | |
| public static final int | MOVE_CURSOR | |
| public static final int | NORMAL | Frame is in the "normal" state. This symbolic constant names a frame state with all state bits cleared. |
| public static final int | ICONIFIED | This state bit indicates that frame is iconified. |
| 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.
|
| public static final int | MAXIMIZED_BOTH | This state bit mask indicates that frame is fully maximized
(that is both horizontally and vertically). It is just a
convenience alias for
MAXIMIZED_VERT | MAXIMIZED_HORIZ.
Note that the correct test for frame being fully maximized is (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH To test is frame is maximized in some direction use (state & Frame.MAXIMIZED_BOTH) != 0
|
| Rectangle | maximizedBounds | Maximized bounds for this frame.
|
| String | title | This is the title of the frame. It can be changed
at any time. title can be null and if
this is the case the title = "".
|
| MenuBar | menuBar | The frames menubar. If menuBar = null
the frame will not have a menubar.
|
| boolean | resizable | This field indicates whether the frame is resizable.
This property can be changed at any time.
resizable will be true if the frame is
resizable, otherwise it will be false.
|
| boolean | undecorated | This field indicates whether the frame is undecorated.
This property can only be changed while the frame is not displayable.
undecorated will be true if the frame is
undecorated, otherwise it will be false.
|
| boolean | mbManagement | mbManagement is only used by the Motif implementation.
|
| Vector | ownedWindows | |
| Fields inherited from java.awt.Container: |
|---|
| ncomponents, component, layoutMgr, containerListener, listeningChildren, listeningBoundsChildren, descendantsCount, INCLUDE_SELF, SEARCH_HEAVYWEIGHTS, modalComp, modalAppContext |
| Constructor: |
|---|
Frame that is
initially invisible. The title of the Frame
is empty.
|
|
Frame object
with the specified title.
|
Frame object
with the specified title and a
GraphicsConfiguration.
|
| Method from java.awt.Frame Summary: |
|---|
| addNotify, constructComponentName, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, postProcessKeyEvent, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
| Methods from java.lang.Object: |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from java.awt.Frame Detail: |
|---|
|
|
|
Deprecated! As - of JDK version 1.1,
replaced by Component.getCursor(). |
|
Warning: this method may return system created frames, such
as a shared, hidden frame which is used by Swing. Applications
should not assume the existence of these frames, nor should an
application assume anything about these frames such as component
positions, Note: To obtain a list of all ownerless windows, including ownerless {@code Dialog}s (introduced in release 1.6), use Window.getOwnerlessWindows . |
This method is obsolete and kept for backward compatibility only. Use Window.getIconImages() instead. If a list of several images was specified as a Window's icon, this method will return the first item of the list. |
Integer.MAX_VALUE to indicate
that system supplied values for this field must be used. |
|
In older versions of JDK a frame state could only be NORMAL or ICONIFIED. Since JDK 1.4 set of supported frame states is expanded and frame state is represented as a bitwise mask.
For compatibility with old programs this method still returns
|
|
|
|
Frame.
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null. |
|
|
|
Deprecated! As - of JDK version 1.1,
replaced by Component.setCursor(Cursor). |
Note that if the state is not supported on a given platform, neither the state nor the return value of the #getExtendedState method will be changed. The application may determine whether a specific state is supported via the java.awt.Toolkit#isFrameStateSupported method. If the frame is currently visible on the screen (the #isShowing method returns {@code true}), the developer should examine the return value of the java.awt.event.WindowEvent#getNewState method of the {@code WindowEvent} received through the java.awt.event.WindowStateListener to determine that the state has actually been changed. If the frame is not visible on the screen, the events may or may not be generated. In this case the developer may assume that the state changes immediately after this method returns. Later, when the {@code setVisible(true)} method is invoked, the frame will attempt to apply this state. Receiving any java.awt.event.WindowEvent#WINDOW_STATE_CHANGED events is not guaranteed in this case also. |
|
When a frame is in maximized state the system supplies some defaults bounds. This method allows some or all of those system supplied values to be overridden.
If On some systems only the size portion of the bounds is taken into account. |
|
|
In older versions of JDK a frame state could only be NORMAL or ICONIFIED. Since JDK 1.4 set of supported frame states is expanded and frame state is represented as a bitwise mask. For compatibility with applications developed earlier this method still accepts {@code Frame.NORMAL} and {@code Frame.ICONIFIED} only. The iconic state of the frame is only changed, other aspects of frame state are not affected by this method. If the state passed to this method is neither {@code Frame.NORMAL} nor {@code Frame.ICONIFIED} the method performs no actions at all. Note that if the state is not supported on a given platform, neither the state nor the return value of the #getState method will be changed. The application may determine whether a specific state is supported via the java.awt.Toolkit#isFrameStateSupported method. If the frame is currently visible on the screen (the #isShowing method returns {@code true}), the developer should examine the return value of the java.awt.event.WindowEvent#getNewState method of the {@code WindowEvent} received through the java.awt.event.WindowStateListener to determine that the state has actually been changed. If the frame is not visible on the screen, the events may or may not be generated. In this case the developer may assume that the state changes immediately after this method returns. Later, when the {@code setVisible(true)} method is invoked, the frame will attempt to apply this state. Receiving any java.awt.event.WindowEvent#WINDOW_STATE_CHANGED events is not guaranteed in this case also. |
|
|