java::awt::Window Class Reference

Inheritance diagram for java::awt::Window:

Inheritance graph
java::awt::Dialogjava::awt::Framejava::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::EventSource
[legend]
Collaboration diagram for java::awt::Window:

Collaboration graph
java::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::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

A Window object is a top-level window with no borders and no menubar.

The default layout for a window is BorderLayout.

A window must have either a frame, dialog, or another window defined as its owner when it's constructed.

In a multi-screen environment, you can create a Window on a different screen device by constructing the Window with Window(Window, 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 device 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 Window 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 a Window 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 Window 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.

	Window w = new Window(Window owner, GraphicsConfiguration gc);
	Rectangle bounds = gc.getBounds();
	w.setLocation(10 + bounds.x, 10 + bounds.y);
 

Windows are capable of generating the following WindowEvents: WindowOpened, WindowClosed, WindowGainedFocus, WindowLostFocus.

Version:
1.184, 01/28/03
Author:
Sami Shaio

Arthur van Hoff

See also:
WindowEvent

addWindowListener

java.awt.BorderLayout

Since:
JDK1.0

Public Member Functions

 Window ()
 Window (const Ref< Window > &owner)
 Constructs a new invisible window with the specified Window as its owner.
virtual void dispose ()
 Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children.
virtual void pack ()
 Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.
virtual void toFront ()
 If this Window is visible, brings this Window to the front and may make it the focused Window.
virtual void toBack ()
 If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.
virtual void setVisible (jboolean b)
 Shows or hides this component depending on the value of parameter b.
virtual Ref< WindowgetOwner () const
 Returns the owner of this window.
virtual Ref< ListgetOwnedWindows () const
 Return an array containing all the windows this window currently owns.
virtual Ref< ListgetListeners (const Class &type) const
 Returns an array of all the objects currently registered as FooListeners upon this Window.
virtual jboolean eventEnabled (const AWTEvent &e) const
virtual void processEvent (const AWTEvent &e)
 Processes events on this window.
virtual void dispatchEvent (AWTEvent &e)
 Dispatches an event to this component or one of its sub components.
virtual String toString () const
 Returns a string representation of this component and its values.

Constructor & Destructor Documentation

java::awt::Window::Window (  ) 

java::awt::Window::Window ( const Ref< Window > &  owner  ) 

Constructs a new invisible window with the specified Window as its owner.

The Window will not be focusable unless its nearest owning Frame or Dialog is showing on the screen.

If there is a security manager, this method first calls the security manager's checkTopLevelWindow method with this as its argument to determine whether or not the window must be displayed with a warning banner.

Parameters:
owner the Window to act as owner
Exceptions:
IllegalArgumentException if the owner's GraphicsConfiguration is not from a screen device
java.lang.IllegalArgumentException if owner is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.
See also:
java.awt.GraphicsEnvironment::isHeadless

java.lang.SecurityManager::checkTopLevelWindow

isShowing

Since:
1.2


Member Function Documentation

virtual void java::awt::Window::dispose (  )  [virtual]

Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children.

That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.

The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed (not accounting for additional modifications between those actions).

Note: When the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for more information.

See also:
Component::isDisplayable

pack

show

virtual void java::awt::Window::pack (  )  [virtual]

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

If the window and/or its owner are not yet displayable, both are made displayable before calculating the preferred size. The Window will be validated after the preferredSize is calculated.

See also:
Component::isDisplayable

virtual void java::awt::Window::toFront (  )  [virtual]

If this Window is visible, brings this Window to the front and may make it the focused Window.

Places this Window at the top of the stacking order and shows it in front of any other Windows in this VM. No action will take place if this Window is not visible. Some platforms do not allow Windows which own other Windows to appear on top of those owned Windows. Some platforms may not permit this VM to place its Windows above windows of native applications, or Windows of other VMs. This permission may depend on whether a Window in this VM is already focused. Every attempt will be made to move this Window as high as possible in the stacking order; however, developers should not assume that this method will move this Window above all other windows in every situation.

Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is the focused or active Window until this Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event. On platforms where the top-most window is the focused window, this method will probably focus this Window, if it is not already focused. On platforms where the stacking order does not typically affect the focused window, this method will probably leave the focused and active Windows unchanged.

If this method causes this Window to be focused, and this Window is a Frame or a Dialog, it will also become activated. If this Window is focused, but it is not a Frame or a Dialog, then the first Frame or Dialog that is an owner of this Window will be activated.

See also:
toBack

virtual void java::awt::Window::toBack (  )  [virtual]

If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.

Places this Window at the bottom of the stacking order and shows it behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however, developers should not assume that this method will move this Window below all other windows in every situation.

Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is no longer the focused or active Window until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED event. On platforms where the top-most window is the focused window, this method will probably cause this Window to lose focus. In that case, the next highest, focusable Window in this VM will receive focus. On platforms where the stacking order does not typically affect the focused window, this method will probably leave the focused and active Windows unchanged.

See also:
toFront

virtual void java::awt::Window::setVisible ( jboolean  b  )  [virtual]

Shows or hides this component depending on the value of parameter b.

Parameters:
b if true, shows this component; otherwise, hides this component
See also:
isVisible
Since:
JDK1.1

Reimplemented from java::awt::Component.

virtual Ref<Window> java::awt::Window::getOwner (  )  const [virtual]

Returns the owner of this window.

Since:
1.2

virtual Ref<List> java::awt::Window::getOwnedWindows (  )  const [virtual]

Return an array containing all the windows this window currently owns.

Since:
1.2

virtual Ref<List> java::awt::Window::getListeners ( const Class type  )  const [virtual]

Returns an array of all the objects currently registered as FooListeners upon this Window.

FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a Window w for its window listeners with the following code:

WindowListener[] wls = (WindowListener[])(w.getListeners(WindowListener.class));

If no such listeners exist, this method returns an empty array.

Parameters:
listenerType the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this window, or an empty array if no such listeners have been added
Exceptions:
ClassCastException if listenerType doesn't specify a class or interface that implements java.util.EventListener
See also:
getWindowListeners
Since:
1.3

Reimplemented from java::awt::Container.

virtual jboolean java::awt::Window::eventEnabled ( const AWTEvent e  )  const [virtual]

Reimplemented from java::awt::Container.

virtual void java::awt::Window::processEvent ( const AWTEvent e  )  [virtual]

Processes events on this window.

If the event is an WindowEvent, it invokes the processWindowEvent method, else it invokes its superclass's processEvent.

Note that if the event parameter is null the behavior is unspecified and may result in an exception.

Parameters:
e the event

Reimplemented from java::awt::Container.

virtual void java::awt::Window::dispatchEvent ( AWTEvent e  )  [virtual]

Dispatches an event to this component or one of its sub components.

Calls processEvent before returning for 1.1-style events which have been enabled for the Component.

Parameters:
e the event

Reimplemented from java::awt::Container.

virtual String java::awt::Window::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::Container.

Reimplemented in java::awt::Dialog, and java::awt::Frame.


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