-
- All Superinterfaces:
Component
,TextGUIElement
- All Known Subinterfaces:
Border
- All Known Implementing Classes:
AbstractBasePane.ContentHolder
,AbstractBasePane.EmptyMenuBar
,AbstractBorder
,AbstractComposite
,Borders.DoubleLine
,Borders.SingleLine
,Borders.StandardBorder
,MenuBar
,Panel
,SplitPanel
public interface Container extends Component
Container is a component that contains a collection of child components. The basic example of an implementation of this is thePanel
class which uses a layout manager to size and position the children over its area. Note that there is no method for adding components to the container, since this depends on the implementation. In general, composites that contains one one (or zero) children, the method for specifying the child is inComposite
. Multi-child containers are generally using thePanel
implementation which has anaddComponent(..)
method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
containsComponent(Component component)
Returnstrue
if this container contains the supplied component either directly or indirectly through intermediate containers.int
getChildCount()
Returns the number of children this container currently hasjava.util.Collection<Component>
getChildren()
Returns collection that is to be considered a copy of the list of children contained inside of this object.java.util.List<Component>
getChildrenList()
Returns list that is to be considered a copy of the list of children inside of this container.boolean
handleInput(KeyStroke key)
If an interactable component inside this container received a keyboard event that wasn't handled, the GUI system will recursively send the event to each parent container to give each of them a chance to consume the event.Interactable
nextFocus(Interactable fromThis)
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.boolean
removeComponent(Component component)
Removes the component from the container.void
updateLookupMap(InteractableLookupMap interactableLookupMap)
Takes a lookup map and updates it with information about where all the interactables inside of this container are located.-
Methods inherited from interface com.googlecode.lanterna.gui2.Component
addTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorder
-
Methods inherited from interface com.googlecode.lanterna.gui2.TextGUIElement
draw, isInvalid
-
-
-
-
Method Detail
-
getChildCount
int getChildCount()
Returns the number of children this container currently has- Returns:
- Number of children currently in this container
-
getChildren
java.util.Collection<Component> getChildren()
Returns collection that is to be considered a copy of the list of children contained inside of this object. Modifying this collection will not affect any internal state.This method isn't deprecated but it should have originally been defined as returning a List instead of a Collection. See
getChildrenList
for a method with this signature.- Returns:
- Child-components inside of this Container
- See Also:
getChildrenList()
-
getChildrenList
java.util.List<Component> getChildrenList()
Returns list that is to be considered a copy of the list of children inside of this container. Modifying this list will not affect any internal state. This method is essentially the same as getChildren but the returned collection is a list.- Returns:
- Child-components inside of this Container
- See Also:
getChildren()
-
containsComponent
boolean containsComponent(Component component)
Returnstrue
if this container contains the supplied component either directly or indirectly through intermediate containers.- Parameters:
component
- Component to check if it's part of this container- Returns:
true
if the component is inside this Container, otherwisefalse
-
removeComponent
boolean removeComponent(Component component)
Removes the component from the container. This should remove the component from the Container's internal data structure as well as call the onRemoved(..) method on the component itself if it was found inside the container.- Parameters:
component
- Component to remove from the Container- Returns:
true
if the component existed inside the container and was removed,false
otherwise
-
nextFocus
Interactable nextFocus(Interactable fromThis)
Given an interactable, find the next one in line to receive focus. If the interactable isn't inside this container, this method should returnnull
.- Parameters:
fromThis
- Component from which to get the next interactable, or if null, pick the first available interactable- Returns:
- The next interactable component, or null if there are no more interactables in the list
-
previousFocus
Interactable previousFocus(Interactable fromThis)
Given an interactable, find the previous one in line to receive focus. If the interactable isn't inside this container, this method should returnnull
.- Parameters:
fromThis
- Component from which to get the previous interactable, or if null, pick the last interactable in the list- Returns:
- The previous interactable component, or null if there are no more interactables in the list
-
handleInput
boolean handleInput(KeyStroke key)
If an interactable component inside this container received a keyboard event that wasn't handled, the GUI system will recursively send the event to each parent container to give each of them a chance to consume the event. Returnfalse
if the implementer doesn't care about this particular keystroke and it will be automatically sent up the hierarchy the to next container. If you returntrue
, the event will stop here and won't be reported as unhandled.- Parameters:
key
- Keystroke that was ignored by the interactable inside this container- Returns:
true
if this event was handled by this container and shouldn't be processed anymore,false
if the container didn't take any action on the event and want to pass it on
-
updateLookupMap
void updateLookupMap(InteractableLookupMap interactableLookupMap)
Takes a lookup map and updates it with information about where all the interactables inside of this container are located.- Parameters:
interactableLookupMap
- Interactable map to update
-
-