java::awt::Frame Class Reference

Inheritance diagram for java::awt::Frame:

Inheritance graph
java::awt::Windowjava::awt::Containerjava::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::ContainerSourcejava::awt::event::WindowSourcejava::lang::Lockjava::lang::ScopeAdapterjava::awt::image::ImageObserverjava::util::EventSourcejava::awt::MenuContainer
[legend]
Collaboration diagram for java::awt::Frame:

Collaboration graph
java::awt::Windowjava::awt::Containerjava::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::ContainerSourcejava::awt::event::WindowSourcejava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::awt::image::ImageObserverjava::util::EventSourcejava::util::Collectionjava::awt::MenuContainerjava::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

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.

MultiScreen.gif

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:

Version:
1.139, 01/23/03
Author:
Sami Shaio
See also:
WindowEvent

Window::addWindowListener

Since:
JDK1.0

Public Types

enum  FRAME_STATE {
  FRAME_NORMAL = 0, FRAME_ICONIFIED = 1, FRAME_MAXIMIZED_HORIZ = 2, FRAME_MAXIMIZED_VERT = 4,
  FRAME_MAXIMIZED_BOTH = FRAME_MAXIMIZED_VERT | FRAME_MAXIMIZED_HORIZ
}

Public Member Functions

 Frame (const String &title=nilString, const Ref< Frame > &owner=0)
 Constructs a new instance of Frame that is initially invisible.
virtual String getTitle () const
 Gets the title of the frame.
virtual void setTitle (const String &title)
 Sets the title for this frame to the specified string.
virtual Ref< ImagegetIconImage () const
 Gets the image to be displayed in the minimized icon for this frame.
virtual void setIconImage (const Ref< Image > &image)
 Sets the image to be displayed in the minimized icon for this frame.
virtual Ref< MenuBargetMenuBar () const
 Gets the menu bar for this frame.
virtual void setMenuBar (const Ref< MenuBar > &mb)
 Sets the menu bar for this frame to the specified menu bar.
virtual jboolean isResizable () const
 Indicates whether this frame is resizable by the user.
virtual void setResizable (jboolean resizable)
 Sets whether this frame is resizable by the user.
virtual jint getState () const
 Gets the state of this frame.
virtual void setState (jint state)
 Sets the state of this frame.
virtual Ref< RectanglegetMaximizedBounds () const
 Gets maximized bounds for this frame.
virtual void setMaximizedBounds (const Ref< Rectangle > &bounds)
 Sets the maximized bounds for this frame.
virtual jboolean isUndecorated () const
 Indicates whether this frame is undecorated.
virtual void setUndecorated (jboolean undecorated)
 Disables or enables decorations for this frame.
virtual Ref< FontgetFont () const
 Gets the font of this component.
virtual void remove (const Ref< MenuComponent > &m)
 Removes the specified menu bar from this frame.
virtual String toString () const
 Returns a string representation of this component and its values.

Static Public Member Functions

static Ref< ListgetFrame ()
 Returns an array containing all Frames created by the application.

Protected Attributes

 REGISTER_MEMBERS

Member Enumeration Documentation

enum java::awt::Frame::FRAME_STATE

Enumerator:
FRAME_NORMAL  Frame is in the "normal" state.

This symbolic constant names a frame state with all state bits cleared.

See also:
setExtendedState(int)

getExtendedState

FRAME_ICONIFIED  This state bit indicates that frame is iconified.

See also:
setExtendedState(int)

getExtendedState

FRAME_MAXIMIZED_HORIZ  This state bit indicates that frame is maximized in the horizontal direction.

See also:
setExtendedState(int)

getExtendedState

Since:
1.4
FRAME_MAXIMIZED_VERT  This state bit indicates that frame is maximized in the vertical direction.

See also:
setExtendedState(int)

getExtendedState

Since:
1.4
FRAME_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
 

See also:
setExtendedState(int)

getExtendedState

Since:
1.4


Constructor & Destructor Documentation

java::awt::Frame::Frame ( const String title = nilString,
const Ref< Frame > &  owner = 0 
)

Constructs a new instance of Frame that is initially invisible.

The title of the Frame is empty.

Exceptions:
HeadlessException when GraphicsEnvironment.isHeadless() returns true
See also:
java.awt.GraphicsEnvironment::isHeadless()

Component::setSize

Component::setVisible(boolean)


Member Function Documentation

virtual String java::awt::Frame::getTitle (  )  const [virtual]

Gets the title of the frame.

The title is displayed in the frame's border.

Returns:
the title of this frame, or an empty string ("") if this frame doesn't have a title.
See also:
setTitle(String)

virtual void java::awt::Frame::setTitle ( const String title  )  [virtual]

Sets the title for this frame to the specified string.

Parameters:
title the title to be displayed in the frame's border. A null value is treated as an empty string, "".
See also:
getTitle

virtual Ref<Image> java::awt::Frame::getIconImage (  )  const [virtual]

Gets the image to be displayed in the minimized icon for this frame.

Returns:
the icon image for this frame, or null if this frame doesn't have an icon image.
See also:
setIconImage(Image)

virtual void java::awt::Frame::setIconImage ( const Ref< Image > &  image  )  [virtual]

Sets the image to be displayed in the minimized icon for this frame.

Not all platforms support the concept of minimizing a window.

Parameters:
image the icon image to be displayed. If this parameter is null then the icon image is set to the default image, which may vary with platform.
See also:
getIconImage

virtual Ref<MenuBar> java::awt::Frame::getMenuBar (  )  const [virtual]

Gets the menu bar for this frame.

Returns:
the menu bar for this frame, or null if this frame doesn't have a menu bar.
See also:
setMenuBar(MenuBar)

virtual void java::awt::Frame::setMenuBar ( const Ref< MenuBar > &  mb  )  [virtual]

Sets the menu bar for this frame to the specified menu bar.

Parameters:
mb the menu bar being set. If this parameter is null then any existing menu bar on this frame is removed.
See also:
getMenuBar

virtual jboolean java::awt::Frame::isResizable (  )  const [virtual]

Indicates whether this frame is resizable by the user.

By default, all frames are initially resizable.

Returns:
true if the user can resize this frame; false otherwise.
See also:
java.awt.Frame::setResizable(boolean)

virtual void java::awt::Frame::setResizable ( jboolean  resizable  )  [virtual]

Sets whether this frame is resizable by the user.

Parameters:
resizable true if this frame is resizable; false otherwise.
See also:
java.awt.Frame::isResizable

virtual jint java::awt::Frame::getState (  )  const [virtual]

Gets the state of this frame.

The state is represented as a bitwise mask.

Returns:
a bitwise mask of frame state constants
See also:
setExtendedState(int)
Since:
1.4

virtual void java::awt::Frame::setState ( jint  state  )  [virtual]

Sets the state of this frame.

The state is represented as a bitwise mask.

Note that if the state is not supported on a given platform, nothing will happen. The application may determine if a specific state is available via the java.awt.Toolkit::isFrameStateSupported(int state) method.

Parameters:
state a bitwise mask of frame state constants
See also:
getExtendedState

java.awt.Toolkit::isFrameStateSupported(int)

Since:
1.4

virtual Ref<Rectangle> java::awt::Frame::getMaximizedBounds (  )  const [virtual]

Gets maximized bounds for this frame.

Some fields may contain Integer.MAX_VALUE to indicate that system supplied values for this field must be used.

Returns:
maximized bounds for this frame; may be null
See also:
setMaximizedBounds(Rectangle)
Since:
1.4

virtual void java::awt::Frame::setMaximizedBounds ( const Ref< Rectangle > &  bounds  )  [virtual]

Sets the maximized bounds for this frame.

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 bounds is null, accept bounds supplied by the system. If non-null you can override some of the system supplied values while accepting others by setting those fields you want to accept from system to Integer.MAX_VALUE.

On some systems only the size portion of the bounds is taken into account.

Parameters:
bounds bounds for the maximized state
See also:
getMaximizedBounds()
Since:
1.4

virtual jboolean java::awt::Frame::isUndecorated (  )  const [virtual]

Indicates whether this frame is undecorated.

By default, all frames are initially decorated.

Returns:
true if frame is undecorated; false otherwise.
See also:
java.awt.Frame::setUndecorated(boolean)
Since:
1.4

virtual void java::awt::Frame::setUndecorated ( jboolean  undecorated  )  [virtual]

Disables or enables decorations for this frame.

This method can only be called while the frame is not displayable.

Parameters:
undecorated true if no frame decorations are to be enabled; false if frame decorations are to be enabled.
Exceptions:
<code>IllegalComponentStateException</code> if the frame is displayable.
See also:
isUndecorated

Component::isDisplayable

javax.swing.JFrame::setDefaultLookAndFeelDecorated(boolean)

Since:
1.4

virtual Ref<Font> java::awt::Frame::getFont (  )  const [virtual]

Gets the font of this component.

Returns:
this component's font; if a font has not been set for this component, the font of its parent is returned
See also:
setFont
Since:
JDK1.0

Implements java::awt::MenuContainer.

virtual void java::awt::Frame::remove ( const Ref< MenuComponent > &  m  )  [virtual]

Removes the specified menu bar from this frame.

Parameters:
m the menu component to remove. If m is null, then no action is taken

Implements java::awt::MenuContainer.

virtual String java::awt::Frame::toString (  )  const [virtual]

Returns a string representation of this component and its values.

Returns:
a string representation of this component
Since:
JDK1.0

Reimplemented from java::awt::Window.

static Ref<List> java::awt::Frame::getFrame (  )  [static]

Returns an array containing all Frames created by the application.

If called from an applet, the array will only include the Frames accessible by that applet.

Since:
1.2


Member Data Documentation

java::awt::Frame::REGISTER_MEMBERS [protected]

Reimplemented from java::awt::MenuContainer.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:00 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3