public abstract class AbstractContainer extends AbstractComponent implements InteractableContainer, Container
Component.Alignment
Modifier | Constructor and Description |
---|---|
protected |
AbstractContainer() |
Modifier and Type | Method and Description |
---|---|
void |
addComponent(Component component,
LayoutParameter... layoutParameters)
Adds a new subcomponent to this container.
|
void |
addContainerListener(ContainerListener cl) |
void |
addShortcut(char character,
boolean withCtrl,
boolean withAlt,
Action action)
Adds a keyboard shortcut to be invoked when the
Interactable component in focus
within this container didn't handle the keyboard event and the event matches the supplied
character and control key status. |
void |
addShortcut(Key.Kind key,
Action action)
Adds a keyboard shortcut to be invoked when the
Interactable component in focus
within this container didn't handle the keyboard event and the event matches the supplied
Key.Kind . |
protected Iterable<Component> |
components() |
boolean |
containsComponent(Component component)
This method can used to see if a particular component is contained with this objects list of
immediate children.
|
Component |
getComponentAt(int index) |
int |
getComponentCount() |
boolean |
hasInteractable(Interactable interactable)
Returns true if this container contains the
interactable passed in as the parameter |
boolean |
isScrollable()
This method is used by the layout system when it needs to shrink components
because the available space is too small.
|
Interactable |
nextFocus(Interactable previous)
Given an interactable, find the next one in line to receive focus.
|
Interactable |
previousFocus(Interactable fromThis)
Given an interactable, find the previous one in line to receive focus.
|
void |
removeAllComponents() |
boolean |
removeComponent(Component component)
Removes a component from this container.
|
void |
removeContainerListener(ContainerListener cl) |
boolean |
triggerShortcut(Key key)
Looks for a shortcut that matches this
key and, if one is found, executes it. |
addBorder, addComponentListener, calculatePreferredSize, getAlignment, getComponentListeners, getGUIScreen, getMinimumSize, getParent, getPreferredSize, getWindow, invalidate, isVisible, removeComponentListener, setAlignment, setParent, setPreferredSize, setVisible, transformAccordingToAlignment
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addBorder, addComponentListener, getAlignment, getMinimumSize, getParent, getPreferredSize, getWindow, isVisible, removeComponentListener, repaint, setAlignment, setPreferredSize, setVisible
public void addComponent(Component component, LayoutParameter... layoutParameters)
Container
addComponent
in interface Container
component
- Component to add to this containerlayoutParameters
- Optional parameters to give hits to the layout managerpublic Component getComponentAt(int index)
getComponentAt
in interface Container
index
- Index to look up a component atpublic boolean containsComponent(Component component)
Container
containsComponent
in interface Container
component
- Component to search fortrue
is the component is found in this containers list of direct children,
otherwise false
public int getComponentCount()
getComponentCount
in interface Container
public boolean removeComponent(Component component)
Container
removeComponent
in interface Container
component
- Component to remove from this containertrue
if a component was found and removed, false
otherwisepublic void removeAllComponents()
public boolean isScrollable()
Component
isScrollable
in interface Component
isScrollable
in class AbstractComponent
public void addContainerListener(ContainerListener cl)
addContainerListener
in interface Container
public void removeContainerListener(ContainerListener cl)
removeContainerListener
in interface Container
public boolean hasInteractable(Interactable interactable)
InteractableContainer
interactable
passed in as the parameterhasInteractable
in interface InteractableContainer
interactable
- interactable
to look fortrue
if the container has interactable
, otherwise false
public Interactable nextFocus(Interactable previous)
InteractableContainer
nextFocus
in interface InteractableContainer
previous
- Component from which to get the next interactable, or if
null, pick the first available interactablepublic Interactable previousFocus(Interactable fromThis)
InteractableContainer
previousFocus
in interface InteractableContainer
fromThis
- Component from which to get the previous interactable,
or if null, pick the last interactable in the listpublic void addShortcut(Key.Kind key, Action action)
InteractableContainer
Interactable
component in focus
within this container didn't handle the keyboard event and the event matches the supplied
Key.Kind
. Please note that calling addShortcut
with
Key.Kind.NormalKey
will throw IllegalArgumentException
; if you want to add
a keyboard shortcut for a non-special key, please use
addShortcut(char, boolean, boolean, Action)
.addShortcut
in interface InteractableContainer
key
- Kind of key to trigger the shortcutaction
- Action to run, on the event thread, when the shortcut is triggeredpublic void addShortcut(char character, boolean withCtrl, boolean withAlt, Action action)
InteractableContainer
Interactable
component in focus
within this container didn't handle the keyboard event and the event matches the supplied
character and control key status. If you want to add a keyboard shortcut for a special keys,
please use addShortcut(Key.Kind, Action)
.addShortcut
in interface InteractableContainer
character
- Character types on the keyboard to trigger the shortcutwithCtrl
- If true
, ctrl key must be down when the key is typed to trigger;
if false
the ctrl key must be up to triggerwithAlt
- If true
, alt key must be down when the key is typed to trigger;
if false
the alt key must be up to triggeraction
- Action to run, on the event thread, when the shortcut is triggeredpublic boolean triggerShortcut(Key key)
InteractableContainer
key
and, if one is found, executes it.triggerShortcut
in interface InteractableContainer
key
- Key
to check for matching shortcutstrue
if a shortcut was triggered and executed, false
otherwise.Copyright © 2015. All Rights Reserved.