Package org.apache.pivot.wtk
Class Container
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- org.apache.pivot.wtk.Container
-
- All Implemented Interfaces:
java.lang.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
,VFSBrowser
,Viewport
,Window
public abstract class Container extends Component implements Sequence<Component>, java.lang.Iterable<Component>
Abstract base class for containers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Container.EDTChecker
-
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
Constructors Constructor Description Container()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
java.awt.Graphics2D
getGraphics()
Creates a graphics context for this component.int
getLength()
Returns the length of the sequence.Component
getNamedComponent(java.lang.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()
java.util.Iterator<Component>
iterator()
protected void
layout()
Called to lay out the component.void
load(java.lang.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(java.awt.Graphics2D graphics)
Paints the component.Sequence<Component>
remove(int index, int count)
Removes one or more items from the sequence.int
remove(Component component)
Removes the first occurrence of the given item 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.EDTChecker checker)
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(java.lang.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
checkSkin, clearFocus, contains, copyStyle, copyStyle, 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, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, 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, offsetToScreen, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, 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
-
-
-
-
Method Detail
-
add
public final int add(Component component)
Description copied from interface:Sequence
Adds an item 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.
-
update
@UnsupportedOperation public Component update(int index, Component component)
Description copied from interface:Sequence
Updates the item 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 interfaceSequence<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.
-
move
public void move(int from, int to)
Moves a component within the component sequence.- Parameters:
from
- The index where the component is currently located.to
- The index to move it to.
-
get
public Component get(int index)
Description copied from interface:Sequence
Retrieves the item at the given index.
-
indexOf
public int indexOf(Component component)
Description copied from interface:Sequence
Returns the index of an item in the sequence.
-
getLength
public int getLength()
Description copied from interface:Sequence
Returns the length of the sequence.
-
iterator
public java.util.Iterator<Component> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Component>
-
getComponentAt
public Component getComponentAt(int x, int y)
-
getDescendantAt
public Component getDescendantAt(int x, int y)
-
getNamedComponent
public Component getNamedComponent(java.lang.String name)
-
setVisible
public void setVisible(boolean visible)
Description copied from class:Component
Sets the component's visibility.- Overrides:
setVisible
in classComponent
- 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.
-
paint
public void paint(java.awt.Graphics2D graphics)
Description copied from class:Component
Paints the component. Delegates to the skin.
-
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 ofcomponent
;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 classComponent
- Returns:
true
if the container or one of its descendants gained the focus orfalse
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.- Returns:
- The newly focused 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.
-
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(java.lang.Object context)
Propagates binding to subcomponents.
-
store
public void store(java.lang.Object context)
Propagates binding to subcomponents.
-
clear
public void clear()
Propagates clear operation to subcomponents.
-
mouseDown
protected boolean mouseDown(Mouse.Button button, int x, int y)
-
mouseUp
protected boolean mouseUp(Mouse.Button button, int x, int y)
-
mouseClick
protected boolean mouseClick(Mouse.Button button, int x, int y, int count)
- Overrides:
mouseClick
in classComponent
-
mouseWheel
protected boolean mouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
- Overrides:
mouseWheel
in classComponent
-
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 classComponent
-
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.
-
getGraphics
public java.awt.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 classComponent
- 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.EDTChecker checker)
-
-