java.awt
Class Window

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
All Implemented Interfaces:
java.awt.image.ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
Dialog, Frame

public class Window
extends Container

A Window object is a top-level window with no borders and no menubar. It could be used to implement a pop-up menu. The default layout for a window is BorderLayout. A Window object blocks input to other application windows when it is shown.

Windows are capable of generating the following window events: WindowOpened, WindowClosed.

Compatibility

The direct creation of Window objects is an optional feature in PersonalJava and Personal Profile implementations. If the implementation prohibits the direct creation of Window objects, the constructor throws and UnsupportedOperationException.

System Properties

java.awt.SupportsWindow is set to "true" or "false" indicating if the platform supports direct creation of window objects.

Since:
JDK1.0
See Also:
WindowEvent, addWindowListener(java.awt.event.WindowListener), BorderLayout, Serialized Form

Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Window(Frame parent)
          Constructs a new invisible window.
 
Method Summary
 void addWindowListener(java.awt.event.WindowListener l)
          Adds the specified window listener to receive window events from this window.
 void dispose()
          Disposes of this window.
 Component getFocusOwner()
          Returns the child component of this Window which has focus if and only if this Window is active.
 Graphics getGraphics()
          Creates a graphics context for this component.
 java.awt.Insets getInsets()
          Determines the insets of this container, which indicate the size of the container's border.
 Locale getLocale()
          Gets the Locale object that is associated with this window, if the locale has been set.
 Toolkit getToolkit()
          Returns the toolkit of this frame.
 String getWarningString()
          Gets the warning string that is displayed with this window.
 boolean isShowing()
          Checks if this Window is showing on screen.
 void pack()
          Causes subcomponents of this window to be laid out at their preferred size.
 boolean postEvent(Event e)
          Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).
protected  void processEvent(AWTEvent e)
          Processes events on this window.
protected  void processWindowEvent(java.awt.event.WindowEvent e)
          Processes window events occurring on this window by dispatching them to any registered WindowListener objects.
 void removeWindowListener(java.awt.event.WindowListener l)
          Removes the specified window listener so that it no longer receives window events from this window.
 void repaint(long tm, int x, int y, int width, int height)
          Repaints the specified rectangle of this component within tm milliseconds.
 void setBackground(java.awt.Color c)
          Sets the background color of this component.
 void setCursor(java.awt.Cursor cursor)
          Set the cursor image to a predefined cursor.
 void show()
          Shows this window, and brings it to the front.
 void toBack()
          Sends this window to the back.
 void toFront()
          Brings this window to the front.
 void update(Graphics g)
          Updates the container.
 void validate()
          Validates this container and all of its subcomponents.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setLayout, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, getBackground, getBounds, getColorModel, getCursor, getFont, getFontMetrics, getForeground, getLocation, getLocationOnScreen, getName, getParent, getSize, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBounds, setBounds, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Window

public Window(Frame parent)
Constructs a new invisible window.

The window is not initially visible. Call the show method to cause the window to become visible.

Parameters:
parent - the main application frame.
Throws:
UnsupportedOperationException - if the implementation does not allow the direct creation of window objects.
Since:
JDK1.0
See Also:
show(), Component.setSize(int, int)
Method Detail

pack

public void pack()
Causes subcomponents of this window to be laid out at their preferred size.

Since:
JDK1.0

getGraphics

public Graphics getGraphics()
Creates a graphics context for this component. This method will return null if this component is currently not on the screen.

Overrides:
getGraphics in class Component
Returns:
A graphics context for this component, or null if it has none.
Since:
JDK1.0
See Also:
Component.paint(java.awt.Graphics)

validate

public void validate()
Description copied from class: Container
Validates this container and all of its subcomponents.

AWT uses validate to cause a container to lay out its subcomponents again after the components it contains have been added to or modified.

Overrides:
validate in class Container
See Also:
Container.validate(), Component.invalidate()

update

public void update(Graphics g)
Description copied from class: Container
Updates the container. This forwards the update to any lightweight components that are children of this container. If this method is reimplemented, super.update(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g, update() will not be forwarded to that child.

Overrides:
update in class Container
Parameters:
g - the specified Graphics window
See Also:
Component.update(java.awt.Graphics)

show

public void show()
Shows this window, and brings it to the front.

If this window is not yet visible, show makes it visible. If this window is already visible, then this method brings it to the front.

Overrides:
show in class Component
Since:
JDK1.0
See Also:
toFront(), Component.setVisible(boolean)

dispose

public void dispose()
Disposes of this window. This method must be called to release the resources that are used for the window.

Since:
JDK1.0

toFront

public void toFront()
Brings this window to the front. Places this window at the top of the stacking order and shows it in front of any other windows.

Since:
JDK1.0
See Also:
toBack()

toBack

public void toBack()
Sends this window to the back. Places this window at the bottom of the stacking order and makes the corresponding adjustment to other visible windows.

Since:
JDK1.0
See Also:
toFront()

getToolkit

public Toolkit getToolkit()
Returns the toolkit of this frame.

Overrides:
getToolkit in class Component
Returns:
the toolkit of this window.
Since:
JDK1.0
See Also:
Toolkit, Toolkit.getDefaultToolkit(), Component.getToolkit()

getWarningString

public final String getWarningString()
Gets the warning string that is displayed with this window. If this window is insecure, the warning string is displayed somewhere in the visible area of the window. A window is insecure if there is a security manager, and the security manager's checkTopLevelWindow method returns false when this window is passed to it as an argument.

If the window is secure, then getWarningString returns null. If the window is insecure, this method checks for the system property awt.appletWarning and returns the string value of that property.

Returns:
the warning string for this window.
Since:
JDK1.0
See Also:
SecurityManager.checkTopLevelWindow(java.lang.Object)

getLocale

public Locale getLocale()
Gets the Locale object that is associated with this window, if the locale has been set. If no locale has been set, then the default locale is returned.

Overrides:
getLocale in class Component
Returns:
the locale that is set for this window.
Since:
JDK1.1
See Also:
Locale

getInsets

public java.awt.Insets getInsets()
Description copied from class: Container
Determines the insets of this container, which indicate the size of the container's border.

A Frame object, for example, has a top inset that corresponds to the height of the frame's title bar.

Overrides:
getInsets in class Container
Returns:
the insets of this container.
See Also:
Insets, LayoutManager

setBackground

public void setBackground(java.awt.Color c)
Description copied from class: Component
Sets the background color of this component.

Overrides:
setBackground in class Component
See Also:
Component.getBackground()

setCursor

public void setCursor(java.awt.Cursor cursor)
Set the cursor image to a predefined cursor.

Overrides:
setCursor in class Component
Parameters:
cursor - One of the constants defined by the Cursor class. If this parameter is null then the cursor for this window will be set to the type Cursor.DEFAULT_CURSOR .
Since:
JDK1.1
See Also:
Component.getCursor(), Cursor

addWindowListener

public void addWindowListener(java.awt.event.WindowListener l)
Adds the specified window listener to receive window events from this window.

Parameters:
l - the window listener

removeWindowListener

public void removeWindowListener(java.awt.event.WindowListener l)
Removes the specified window listener so that it no longer receives window events from this window.

Parameters:
l - the window listener

processEvent

protected void processEvent(AWTEvent e)
Processes events on this window. If the event is an WindowEvent, it invokes the processWindowEvent method, else it invokes its superclass's processEvent.

Overrides:
processEvent in class Container
Parameters:
e - the event
See Also:
Component.processComponentEvent(java.awt.event.ComponentEvent), Component.processFocusEvent(java.awt.event.FocusEvent), Component.processKeyEvent(java.awt.event.KeyEvent), Component.processMouseEvent(java.awt.event.MouseEvent), Component.processMouseMotionEvent(java.awt.event.MouseEvent)

processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent e)
Processes window events occurring on this window by dispatching them to any registered WindowListener objects. NOTE: This method will not be called unless window events are enabled for this component; this happens when one of the following occurs: a) A WindowListener object is registered via addWindowListener() b) Window events are enabled via enableEvents()

Parameters:
e - the window event
See Also:
Component.enableEvents(long)

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Description copied from class: Component
Repaints the specified rectangle of this component within tm milliseconds.

This method causes a call to this component's update method.

Overrides:
repaint in class Component
Parameters:
tm - maximum time in milliseconds before update.
x - the x coordinate.
y - the y coordinate.
width - the width.
height - the height.
See Also:
Component.update(java.awt.Graphics)

getFocusOwner

public Component getFocusOwner()
Returns the child component of this Window which has focus if and only if this Window is active.

Returns:
the component with focus, or null if no children have focus assigned to them.

postEvent

public boolean postEvent(Event e)
Deprecated. As of JDK version 1.1 replaced by dispatchEvent(AWTEvent).

Specified by:
postEvent in interface MenuContainer
Overrides:
postEvent in class Component

isShowing

public boolean isShowing()
Checks if this Window is showing on screen.

Overrides:
isShowing in class Component
Returns:
true if the component is showing; false otherwise.
See Also:
Component.setVisible(boolean)