pivot.wtk
Class Container

java.lang.Object
  extended by pivot.wtk.Component
      extended by pivot.wtk.Container
All Implemented Interfaces:
Iterable<Component>, Sequence<Component>, ConstrainedVisual, Visual
Direct Known Subclasses:
Accordion, Border, Calendar, CardPane, Display, Expander, FlowPane, Form, Menu, MenuBar, Panel, Rollup, ScrollBar, Slider, Spinner, SplitPane, StackPane, TablePane, TabPane, Viewport, Window

public abstract class Container
extends Component
implements Sequence<Component>, Iterable<Component>

Abstract base class for containers.

NOTES:

Author:
gbrown

Nested Class Summary
 
Nested classes/interfaces inherited from class pivot.wtk.Component
Component.Attributes, Component.ComponentDictionary, Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Nested classes/interfaces inherited from interface pivot.collections.Sequence
Sequence.Search, Sequence.Sort, Sequence.Tree
 
Constructor Summary
Container()
           
 
Method Summary
 int add(Component component)
          Adds an item to the sequence.
 boolean containsFocus()
          Tests whether this container is an ancestor of the currently focused component.
 Component get(int index)
          Retrieves the item at the given index.
 Component getComponentAt(int x, int y)
           
 ListenerList<ContainerListener> getContainerListeners()
           
 ListenerList<ContainerMouseListener> getContainerMouseListeners()
           
 String getContextKey()
          Returns the container's context key.
 Component getDescendantAt(int x, int y)
           
 FocusTraversalPolicy getFocusTraversalPolicy()
          Returns this container's focus traversal policy.
 int getLength()
          Returns the length of the sequence.
 int indexOf(Component component)
          Returns the index of an item in the sequence.
 void insert(Component component, int index)
          Inserts an item into the sequence at a specific index.
 boolean isAncestor(Component component)
          Tests if this container is an ancestor of a given component.
 boolean isFocusable()
          Returns this component's focusability.
 Iterator<Component> iterator()
           
 void load(Dictionary<String,?> context)
          Propagates binding to subcomponents.
protected  boolean mouseClick(Mouse.Button button, int x, int y, int count)
           
protected  boolean mouseDown(Mouse.Button button, int x, int y)
           
protected  boolean mouseMove(int x, int y)
           
protected  void mouseOut()
           
protected  boolean mouseUp(Mouse.Button button, int x, int y)
           
protected  boolean mouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
           
protected  void move(int from, int to)
          Moves a component within the component sequence.
 void paint(Graphics2D graphics)
          Paints the component.
 int remove(Component component)
          Removes the first occurrence of the given item from the sequence.
 Sequence<Component> remove(int index, int count)
          Removes one or more items from the sequence.
 Sequence<Component> removeAll()
           
 void requestFocus()
          Requests that focus be given to this component.
 void setContextKey(String contextKey)
          Sets the component's context key.
 void setEnabled(boolean enabled)
          Sets the component's enabled state.
 void setFocusTraversalPolicy(FocusTraversalPolicy focusTraversalPolicy)
          Sets this container's focus traversal policy.
protected  void setParent(Container parent)
           
 void setTooltip(String tooltip)
          Unsupported for containers.
 void setVisible(boolean visible)
          Sets the component's visibility.
 void store(Dictionary<String,?> context)
          Propagates binding to subcomponents.
 Component update(int index, Component component)
          Updates the item at the given index.
 void validate()
          Lays out the component by calling Skin.layout().
 
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, getGraphics, getHandle, getHeight, getLocation, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipText, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWindow, getX, getY, installSkin, invalidate, isBlocked, isDisplayable, isEnabled, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, load, mapPointFromAncestor, mapPointToAncestor, mouseOver, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttributes, setCursor, setCursor, setDisplayable, setDragSource, setDropTarget, setFocused, setHeight, setLocation, setLocation, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyles, setStyles, setStyles, setTooltipText, setWidth, setX, setY, store, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Container

public Container()
Method Detail

add

public final int add(Component component)
Description copied from interface: Sequence
Adds an item to the sequence.

Specified by:
add in interface Sequence<Component>
Parameters:
component - The item to be added to the sequence.
Returns:
The index at which the item was added.

insert

public void insert(Component component,
                   int index)
Description copied from interface: Sequence
Inserts an item into the sequence at a specific index.

Specified by:
insert in interface Sequence<Component>
Parameters:
component - The item to be added to the sequence.
index - The index at which the item should be inserted. Must be a value between 0 and getLength().

update

public Component update(int index,
                        Component component)
Description copied from interface: Sequence
Updates the item at the given index.

Specified by:
update in interface Sequence<Component>
Parameters:
index - The index of the item to update.
component - The item that will replace any existing value at the given index.
Returns:
The item that was previously stored at the given index.

remove

public final int remove(Component component)
Description copied from interface: Sequence
Removes the first occurrence of the given item from the sequence.

Specified by:
remove in interface Sequence<Component>
Parameters:
component - The item to remove.
Returns:
The index of the item that was removed, or -1 if the item could not be found.
See Also:
Sequence.remove(int, int)

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>
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.

removeAll

public final Sequence<Component> removeAll()

move

protected void move(int from,
                    int to)
Moves a component within the component sequence. This method does not fire any events; it is the caller's responsibility to ensure that appropriate events are fired (see WindowListener.windowMoved(Window, int, int) as an example).

Parameters:
from -
to -

get

public Component get(int index)
Description copied from interface: Sequence
Retrieves the item at the given index.

Specified by:
get in interface Sequence<Component>
Parameters:
index - The index of the item to retrieve.

indexOf

public int indexOf(Component component)
Description copied from interface: Sequence
Returns the index of an item in the sequence.

Specified by:
indexOf in interface Sequence<Component>
Parameters:
component - The item to locate.
Returns:
The index of first occurrence of the item if it exists in the sequence; -1, otherwise.

getLength

public int getLength()
Description copied from interface: Sequence
Returns the length of the sequence.

Specified by:
getLength in interface Sequence<Component>
Returns:
The number of items in the sequence.

iterator

public Iterator<Component> iterator()
Specified by:
iterator in interface Iterable<Component>

setParent

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

getComponentAt

public Component getComponentAt(int x,
                                int y)

getDescendantAt

public Component getDescendantAt(int x,
                                 int y)

setVisible

public void setVisible(boolean visible)
Description copied from class: Component
Sets the component's visibility.

NOTE This method should only be called during layout. Callers should use Component.setDisplayable(boolean).

Overrides:
setVisible in class Component
Parameters:
visible - true if the component should be painted; false, otherwise.

validate

public void validate()
Description copied from class: Component
Lays out the component by calling Skin.layout().

Overrides:
validate in class Component

paint

public void paint(Graphics2D graphics)
Description copied from class: Component
Paints the component. Delegates to the skin.

Specified by:
paint in interface Visual
Overrides:
paint in class Component
Parameters:
graphics - The graphics context in which to paint the visual.

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: Component
Sets the component's enabled state. Enabled components respond to user input events; disabled components do not.

Overrides:
setEnabled in class Component
Parameters:
enabled - true if the component is enabled; false, otherwise.

setTooltip

public void setTooltip(String tooltip)
Unsupported for containers. Only leaf components can have tooltips.


isAncestor

public boolean isAncestor(Component component)
Tests if this container is an ancestor of a given component. A container is considered to be its own ancestor.

Parameters:
component - The component to test.
Returns:
true if this container is an ancestor of component; false otherwise.

isFocusable

public final boolean isFocusable()
Description copied from class: Component
Returns this component's focusability. A focusable component is capable of receiving the focus.

Overrides:
isFocusable in class Component
Returns:
false; containers are not focusable.

requestFocus

public void requestFocus()
Description copied from class: Component
Requests that focus be given to this component.

Overrides:
requestFocus in class Component

getFocusTraversalPolicy

public FocusTraversalPolicy getFocusTraversalPolicy()
Returns this container's focus traversal policy.


setFocusTraversalPolicy

public void setFocusTraversalPolicy(FocusTraversalPolicy focusTraversalPolicy)
Sets this container's focus traversal policy.

Parameters:
focusTraversalPolicy - The focus traversal policy to use with this container.

containsFocus

public boolean containsFocus()
Tests whether this container is an ancestor of the currently focused component.

Returns:
true if a component is focused and this container is an ancestor of the component; false, otherwise.

getContextKey

public String getContextKey()
Returns the container's context key.

Returns:
The context key, or null if no context key is set.

setContextKey

public void setContextKey(String contextKey)
Sets the component's context key.

Parameters:
contextKey - The context key, or null to clear the context.

load

public void load(Dictionary<String,?> context)
Propagates binding to subcomponents. If this container has a binding set, propagates the bound value as a nested context.

Overrides:
load in class Component
Parameters:
context -

store

public void store(Dictionary<String,?> context)
Propagates binding to subcomponents. If this container has a binding set, propagates the bound value as a nested context.

Overrides:
store in class Component
Parameters:
context -

mouseMove

protected boolean mouseMove(int x,
                            int y)
Overrides:
mouseMove in class Component

mouseOut

protected void mouseOut()
Overrides:
mouseOut in class Component

mouseDown

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

mouseUp

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

mouseClick

protected boolean mouseClick(Mouse.Button button,
                             int x,
                             int y,
                             int count)
Overrides:
mouseClick in class Component

mouseWheel

protected boolean mouseWheel(Mouse.ScrollType scrollType,
                             int scrollAmount,
                             int wheelRotation,
                             int x,
                             int y)
Overrides:
mouseWheel in class Component

getContainerListeners

public ListenerList<ContainerListener> getContainerListeners()

getContainerMouseListeners

public ListenerList<ContainerMouseListener> getContainerMouseListeners()