org.apache.pivot.wtk
Class Container

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

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

Abstract base class for containers.


Nested Class Summary
static interface Container.EDT_Checker
           
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
 
Constructor Summary
Container()
           
 
Method Summary
 int add(Component component)
          Adds an item to the sequence.
protected  void assertEventDispatchThread()
           
static void assertEventDispatchThread(Component component)
           
 void clear()
          Propagates clear operation to subcomponents.
 boolean containsFocus()
          Tests whether this container is an ancestor of the currently focused component.
protected  void descendantAdded(Component descendant)
           
protected  void descendantGainedFocus(Component descendant, Component previousFocusedComponent)
           
protected  void descendantLostFocus(Component descendant)
           
protected  void descendantRemoved(Component descendant)
           
 Component get(int index)
          Retrieves the item at the given index.
 Component getComponentAt(int x, int y)
           
 ListenerList<ContainerListener> getContainerListeners()
           
 ListenerList<ContainerMouseListener> getContainerMouseListeners()
           
 Component getDescendantAt(int x, int y)
           
 FocusTraversalPolicy getFocusTraversalPolicy()
          Returns this container's focus traversal policy.
 Graphics2D getGraphics()
          Creates a graphics context for this component.
 int getLength()
          Returns the length of the sequence.
 Component getNamedComponent(String name)
           
 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.
 void invalidate()
          Flags the component's hierarchy as invalid, and clears any cached preferred size.
 boolean isAncestor(Component component)
          Tests if this container is an ancestor of a given component.
 boolean isDoubleBuffered()
           
 Iterator<Component> iterator()
           
protected  void layout()
          Called to lay out the component.
 void load(Object 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)
           
 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 repaint(int x, int y, int width, int height, boolean immediate)
          Flags an area as needing to be repainted.
 boolean requestFocus()
          Requests that focus be given to this container.
 void setDoubleBuffered(boolean b)
           
static void setEventDispatchThreadChecker(Container.EDT_Checker runnable)
           
 void setFocusTraversalPolicy(FocusTraversalPolicy focusTraversalPolicy)
          Sets this container's focus traversal policy.
protected  void setParent(Container parent)
           
 void setVisible(boolean visible)
          Sets the component's visibility.
 void store(Object context)
          Propagates binding to subcomponents.
 Component transferFocus(Component component, FocusTraversalDirection direction)
          Transfers focus to the next focusable component.
 Component update(int index, Component component)
          Updates the item at the given index.
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, contains, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseOver, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setSkin, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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, or -1 if the item was not added to the sequence.

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

public void move(int from,
                 int to)
Moves a component within the component sequence.

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)

getNamedComponent

public Component getNamedComponent(String name)

setVisible

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

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

layout

protected void layout()
Description copied from class: Component
Called to lay out the component.

Overrides:
layout 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.

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.

requestFocus

public boolean requestFocus()
Requests that focus be given to this container. If this container is not focusable, this requests that focus be set to the first focusable descendant in this container.

Overrides:
requestFocus in class Component
Returns:
true if the container or one of its descendants gained the focus or false if no component was found to gain the focus.

transferFocus

public Component transferFocus(Component component,
                               FocusTraversalDirection direction)
Transfers focus to the next focusable component.

Parameters:
component - The component from which focus will be transferred.
direction - The direction in which to transfer focus.

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.

descendantAdded

protected void descendantAdded(Component descendant)

descendantRemoved

protected void descendantRemoved(Component descendant)

descendantGainedFocus

protected void descendantGainedFocus(Component descendant,
                                     Component previousFocusedComponent)

descendantLostFocus

protected void descendantLostFocus(Component descendant)

load

public void load(Object context)
Propagates binding to subcomponents.

Overrides:
load in class Component
Parameters:
context -

store

public void store(Object context)
Propagates binding to subcomponents.

Overrides:
store in class Component
Parameters:
context -

clear

public void clear()
Propagates clear operation to subcomponents.

Overrides:
clear in class Component

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

invalidate

public void invalidate()
Description copied from class: Component
Flags the component's hierarchy as invalid, and clears any cached preferred size.

Overrides:
invalidate in class Component

repaint

public void repaint(int x,
                    int y,
                    int width,
                    int height,
                    boolean immediate)
Description copied from class: Component
Flags an area as needing to be repainted.

Overrides:
repaint in class Component

getGraphics

public Graphics2D getGraphics()
Description copied from class: Component
Creates a graphics context for this component. This graphics context will not be double buffered. In other words, drawing operations on it will operate directly on the video RAM.

Overrides:
getGraphics in class Component
Returns:
A graphics context for this component, or null if this component is not showing.
See Also:
Component.isShowing()

isDoubleBuffered

public boolean isDoubleBuffered()

setDoubleBuffered

public void setDoubleBuffered(boolean b)

getContainerListeners

public ListenerList<ContainerListener> getContainerListeners()

getContainerMouseListeners

public ListenerList<ContainerMouseListener> getContainerMouseListeners()

assertEventDispatchThread

protected final void assertEventDispatchThread()

assertEventDispatchThread

public static final void assertEventDispatchThread(Component component)

setEventDispatchThreadChecker

public static final void setEventDispatchThreadChecker(Container.EDT_Checker runnable)