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 interfaceContainer.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 intadd(Component component)Adds an item to the sequence.protected voidassertEventDispatchThread()static voidassertEventDispatchThread(Component component)voidclear()Propagates clear operation to subcomponents.booleancontainsFocus()Tests whether this container is an ancestor of the currently focused component.protected voiddescendantAdded(Component descendant)protected voiddescendantGainedFocus(Component descendant, Component previousFocusedComponent)protected voiddescendantLostFocus(Component descendant)protected voiddescendantRemoved(Component descendant)Componentget(int index)Retrieves the item at the given index.ComponentgetComponentAt(int x, int y)ListenerList<ContainerListener>getContainerListeners()ListenerList<ContainerMouseListener>getContainerMouseListeners()ComponentgetDescendantAt(int x, int y)FocusTraversalPolicygetFocusTraversalPolicy()java.awt.Graphics2DgetGraphics()Creates a graphics context for this component.intgetLength()Returns the length of the sequence.ComponentgetNamedComponent(java.lang.String name)intindexOf(Component component)Returns the index of an item in the sequence.voidinsert(Component component, int index)Inserts an item into the sequence at a specific index.voidinvalidate()Flags the component's hierarchy as invalid, and clears any cached preferred size.booleanisAncestor(Component component)Tests if this container is an ancestor of a given component.booleanisDoubleBuffered()java.util.Iterator<Component>iterator()protected voidlayout()Called to lay out the component.voidload(java.lang.Object context)Propagates binding to subcomponents.protected booleanmouseClick(Mouse.Button button, int x, int y, int count)protected booleanmouseDown(Mouse.Button button, int x, int y)protected booleanmouseMove(int x, int y)protected voidmouseOut()protected booleanmouseUp(Mouse.Button button, int x, int y)protected booleanmouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)voidmove(int from, int to)Moves a component within the component sequence.voidpaint(java.awt.Graphics2D graphics)Paints the component.Sequence<Component>remove(int index, int count)Removes one or more items from the sequence.intremove(Component component)Removes the first occurrence of the given item from the sequence.Sequence<Component>removeAll()voidrepaint(int x, int y, int width, int height, boolean immediate)Flags an area as needing to be repainted.booleanrequestFocus()Requests that focus be given to this container.voidsetDoubleBuffered(boolean b)static voidsetEventDispatchThreadChecker(Container.EDTChecker checker)voidsetFocusTraversalPolicy(FocusTraversalPolicy focusTraversalPolicy)Sets this container's focus traversal policy.protected voidsetParent(Container parent)voidsetVisible(boolean visible)Sets the component's visibility.voidstore(java.lang.Object context)Propagates binding to subcomponents.ComponenttransferFocus(Component component, FocusTraversalDirection direction)Transfers focus to the next focusable component.Componentupdate(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:SequenceAdds an item to the sequence.
-
insert
public void insert(Component component, int index)
Description copied from interface:SequenceInserts an item into the sequence at a specific index.
-
update
@UnsupportedOperation public Component update(int index, Component component)
Description copied from interface:SequenceUpdates the item at the given index.
-
remove
public final int remove(Component component)
Description copied from interface:SequenceRemoves the first occurrence of the given item from the sequence.- Specified by:
removein interfaceSequence<Component>- Parameters:
component- The item to remove.- Returns:
- The index of the item that was removed, or
-1if 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:SequenceRemoves 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:SequenceRetrieves the item at the given index.
-
indexOf
public int indexOf(Component component)
Description copied from interface:SequenceReturns the index of an item in the sequence.
-
getLength
public int getLength()
Description copied from interface:SequenceReturns the length of the sequence.
-
iterator
public java.util.Iterator<Component> iterator()
- Specified by:
iteratorin 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:ComponentSets the component's visibility.- Overrides:
setVisiblein classComponent- Parameters:
visible-trueif the component should be painted;false, otherwise.
-
layout
protected void layout()
Description copied from class:ComponentCalled to lay out the component.
-
paint
public void paint(java.awt.Graphics2D graphics)
Description copied from class:ComponentPaints 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:
trueif this container is an ancestor ofcomponent;falseotherwise.
-
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:
requestFocusin classComponent- Returns:
trueif the container or one of its descendants gained the focus orfalseif 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:
trueif 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:
mouseClickin classComponent
-
mouseWheel
protected boolean mouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
- Overrides:
mouseWheelin classComponent
-
invalidate
public void invalidate()
Description copied from class:ComponentFlags the component's hierarchy as invalid, and clears any cached preferred size.- Overrides:
invalidatein classComponent
-
repaint
public void repaint(int x, int y, int width, int height, boolean immediate)Description copied from class:ComponentFlags an area as needing to be repainted.
-
getGraphics
public java.awt.Graphics2D getGraphics()
Description copied from class:ComponentCreates 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:
getGraphicsin classComponent- Returns:
- A graphics context for this component, or
nullif 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)
-
-