pivot.wtk
Class Window

java.lang.Object
  extended by pivot.wtk.Component
      extended by pivot.wtk.Container
          extended by pivot.wtk.Window
All Implemented Interfaces:
java.lang.Iterable<Component>, Sequence<Component>, ConstrainedVisual, Visual
Direct Known Subclasses:
Frame, MenuPopup, Palette, Sheet, Tooltip

public class Window
extends Container

Top-level container representing the entry point into a user interface. Windows are direct descendants of the display.

Author:
gbrown

Nested Class Summary
 class Window.ActionDictionary
          Action dictionary implementation.
 
Nested classes/interfaces inherited from class pivot.wtk.Component
Component.Attributes, Component.ComponentDictionary, Component.DecoratorSequence, Component.StyleDictionary
 
Nested classes/interfaces inherited from interface pivot.collections.Sequence
Sequence.Search, Sequence.Sort, Sequence.Tree
 
Constructor Summary
Window()
           
Window(boolean auxilliary)
           
Window(Component content)
           
Window(Component content, boolean auxilliary)
           
 
Method Summary
 void align(Bounds bounds, HorizontalAlignment horizontalAlignment, int horizontalOffset, VerticalAlignment verticalAlignment, int verticalOffset)
           
 void align(Bounds bounds, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
           
 void close()
          Closes the window.
 Window.ActionDictionary getActions()
          Returns the global action map for this window.
 Component getActiveDescendant()
          Returns the window descendant that currently has the focus.
static Window getActiveWindow()
          Returns the currently active window.
 Component getContent()
           
 Image getIcon()
          Returns the window's icon.
 Window getOwnedWindow(int index)
           
 int getOwnedWindowCount()
           
 Window getOwner()
           
 Window getRootOwner()
           
 java.lang.String getTitle()
          Returns the window's title.
static ListenerList<WindowClassListener> getWindowClassListeners()
           
 ListenerList<WindowListener> getWindowListeners()
           
 ListenerList<WindowStateListener> getWindowStateListeners()
           
 boolean isActive()
          Returns the window's active state.
 boolean isAuxilliary()
          Returns the window's auxilliary flag.
 boolean isClosed()
          Returns this window's closed state.
 boolean isClosing()
          Returns this window's closing state.
 boolean isMaximized()
           
 boolean isOpen()
          Returns this window's open state.
 boolean isOpening()
          Returns this window's opening state.
 boolean isOwner(Window window)
          Tests whether this window is an owning ancestor of a given window.
protected  boolean mouseDown(Mouse.Button button, int x, int y)
           
 void moveToBack()
          Moves the window to the bottom of the window stack.
 void moveToFront()
          Moves the window to the top of the window stack.
 void open(Display display)
          Opens the window.
 void open(Window owner)
          Opens the window.
 Sequence<Component> remove(int index, int count)
          Removes one or more items from the sequence.
protected  void setActive(boolean active)
          Called to notify a window that its active state has changed.
protected  void setActiveDescendant(Component activeDescendant)
          Sets the window's active descendant, the descendant that currently has the focus.
static void setActiveWindow(Window activeWindow)
          Sets the active window.
 void setContent(Component content)
           
 void setDisplayable(boolean displayable)
          Sets the displayable state of this window and all of its owned descendant windows.
 void setEnabled(boolean enabled)
          Sets the enabled state of this window and all of its owned descendant windows.
 void setIcon(Image icon)
          Sets the window's icon.
 void setIcon(java.lang.String icon)
          Sets the window's icon by resource name.
 void setIcon(java.net.URL icon)
          Sets the window's icon by URL.
 void setMaximized(boolean maximized)
           
 void setOwner(Window owner)
           
protected  void setParent(Container parent)
           
 void setTitle(java.lang.String title)
          Sets the window's title.
 
Methods inherited from class pivot.wtk.Container
add, containsFocus, get, getComponentAt, getContainerListeners, getContainerMouseListeners, getContextKey, getDescendantAt, getFocusTraversalPolicy, getLength, indexOf, insert, invalidate, isAncestor, isFocusable, isValid, iterator, load, load, mouseClick, mouseMove, mouseOut, mouseUp, mouseWheel, move, paint, remove, removeAll, requestFocus, setContextKey, setFocusTraversalPolicy, setTooltip, setVisible, store, store, update, validate
 
Methods inherited from class pivot.wtk.Component
clearFocus, clearFocus, finalize, getAttributes, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentDragDropListeners, getComponentKeyListeners, getComponentLayoutListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponents, getComponentStateListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHandle, getHeight, getLocation, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipText, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWindow, getX, getY, installSkin, isBlocked, isDisplayable, isEnabled, isFocused, isMouseOver, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointToAncestor, mouseOver, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttributes, setCursor, setCursor, setDragSource, setDropTarget, setFocused, setLocation, setLocation, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyles, setStyles, setStyles, setTooltipText, setUserData, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Window

public Window()

Window

public Window(boolean auxilliary)

Window

public Window(Component content)

Window

public Window(Component content,
              boolean auxilliary)
Method Detail

setParent

protected void setParent(Container parent)
Overrides:
setParent in class Container

remove

public Sequence<Component> remove(int index,
                                  int count)
Description copied from interface: Sequence
Removes one or more items from the sequence.

Specified by:
remove in interface Sequence<Component>
Overrides:
remove in class Container
Parameters:
index - The starting index to remove.
count - The number of items to remove, beginning with index.
Returns:
A sequence containing the items that were removed.

setDisplayable

public void setDisplayable(boolean displayable)
Sets the displayable state of this window and all of its owned descendant windows.

Overrides:
setDisplayable in class Component
Parameters:
displayable - If true, the window and its owned descendants are displayable; otherwise, they are not displayable.

setEnabled

public void setEnabled(boolean enabled)
Sets the enabled state of this window and all of its owned descendant windows.

Overrides:
setEnabled in class Container
Parameters:
enabled - If true, the window and its owned descendants are enabled; otherwise, they are not enabled.

getOwner

public Window getOwner()

setOwner

public void setOwner(Window owner)

getRootOwner

public Window getRootOwner()

getOwnedWindow

public Window getOwnedWindow(int index)

getOwnedWindowCount

public int getOwnedWindowCount()

isOwner

public boolean isOwner(Window window)
Tests whether this window is an owning ancestor of a given window. A window is not considered an owner of itself.

Parameters:
window -
Returns:
true if this window is an owning ancestor of the given window; false, otherwise.

isOpen

public boolean isOpen()
Returns this window's open state.

Returns:
true if the window is open; false, otherwise.

isOpening

public boolean isOpening()
Returns this window's opening state.

Returns:
true if the window is open; false, otherwise.

open

public void open(Display display)
Opens the window. Opening a window adds it to the display's component sequence. If the window is activatable, it will become the active window.

Parameters:
display - The display on which the window will be opened.

open

public void open(Window owner)
Opens the window.

Parameters:
owner - The window's owner.

isClosed

public boolean isClosed()
Returns this window's closed state.

Returns:
true if the window is closed; false, otherwise.

isClosing

public boolean isClosing()
Returns this window's closing state.

Returns:
true if the window is closing; false, otherwise.

close

public void close()
Closes the window. Closing a window closes all owned windows and removes the window from the display's component sequence. If the window was the active window, the active window will be cleared. If the window was the focus host, the focused component will be cleared.


getTitle

public java.lang.String getTitle()
Returns the window's title.

Returns:
The pane's title, or null if no title is set.

setTitle

public void setTitle(java.lang.String title)
Sets the window's title.

Parameters:
title - The new title, or null for no title.

getIcon

public Image getIcon()
Returns the window's icon.

Returns:
The window's icon, or null if the window has no icon.

setIcon

public void setIcon(Image icon)
Sets the window's icon.

Parameters:
icon - The window's icon, or null for no icon.

setIcon

public void setIcon(java.net.URL icon)
Sets the window's icon by URL.

Parameters:
icon - The location of the icon to set.

setIcon

public void setIcon(java.lang.String icon)
Sets the window's icon by resource name.

Parameters:
icon - The resource name of the icon to set.

getContent

public Component getContent()

setContent

public void setContent(Component content)

isAuxilliary

public boolean isAuxilliary()
Returns the window's auxilliary flag. Auxilliary windows must have an owner, can't become active, and can only own other auxilliary windows.

Returns:
true if this is an auxilliary window; false, otherwise.

isActive

public boolean isActive()
Returns the window's active state.

Returns:
true if the window is active; false; otherwise.

setActive

protected void setActive(boolean active)
Called to notify a window that its active state has changed.

Parameters:
active -

getActiveWindow

public static Window getActiveWindow()
Returns the currently active window.

Returns:
The window that is currently active, or null if no window is active.

setActiveWindow

public static void setActiveWindow(Window activeWindow)
Sets the active window. The window must be activatable, open, and enabled. If the window is not currently visible, it will be made visible.

Parameters:
activeWindow - The window to activate, or null to clear the active window.

getActiveDescendant

public Component getActiveDescendant()
Returns the window descendant that currently has the focus.


setActiveDescendant

protected void setActiveDescendant(Component activeDescendant)
Sets the window's active descendant, the descendant that currently has the focus.

Parameters:
activeDescendant -

getActions

public Window.ActionDictionary getActions()
Returns the global action map for this window.


moveToFront

public void moveToFront()
Moves the window to the top of the window stack. The window is removed from its current position in the display's component sequence and appended to the end. It is also moved to the top of its owner's owned window list so it becomes top-most of all windows owned by its owner.

All windows owned by this window are subsequently moved to the front, ensuring that this window's owned windows remain on top of it.

Finally, the window is made active and focus is restored to the most recently focused decendant component.


moveToBack

public void moveToBack()
Moves the window to the bottom of the window stack. If the window is active, the active window will be cleared. If the window is the focus host, the focus will be cleared.


isMaximized

public boolean isMaximized()

setMaximized

public void setMaximized(boolean maximized)

align

public void align(Bounds bounds,
                  HorizontalAlignment horizontalAlignment,
                  VerticalAlignment verticalAlignment)

align

public void align(Bounds bounds,
                  HorizontalAlignment horizontalAlignment,
                  int horizontalOffset,
                  VerticalAlignment verticalAlignment,
                  int verticalOffset)

mouseDown

protected boolean mouseDown(Mouse.Button button,
                            int x,
                            int y)
Overrides:
mouseDown in class Container

getWindowListeners

public ListenerList<WindowListener> getWindowListeners()

getWindowStateListeners

public ListenerList<WindowStateListener> getWindowStateListeners()

getWindowClassListeners

public static ListenerList<WindowClassListener> getWindowClassListeners()