Component, Container, TextGUIElementpublic class Panel extends AbstractComponent<Panel> implements Container
Container that supports multiple children. A Panel is a component that can contain one or more
other components, including nested panels. The panel itself doesn't have any particular appearance and isn't
interactable by itself, although you can set a border for the panel and interactable components inside the panel will
receive input focus as expected.| Modifier and Type | Class | Description |
|---|---|---|
class |
Panel.DefaultPanelRenderer |
| Constructor | Description |
|---|---|
Panel() |
Default constructor, creates a new panel with no child components and by default set to a vertical
LinearLayout layout manager. |
Panel(LayoutManager layoutManager) |
| Modifier and Type | Method | Description |
|---|---|---|
Panel |
addComponent(int index,
Component component) |
Adds a new child component to the panel.
|
Panel |
addComponent(Component component) |
Adds a new child component to the panel.
|
Panel |
addComponent(Component component,
LayoutData layoutData) |
This method is a shortcut for calling:
|
TerminalSize |
calculatePreferredSize() |
Invokes the component renderer's size calculation logic and returns the result.
|
boolean |
containsComponent(Component component) |
Returns
true if this container contains the supplied component either directly or indirectly through
intermediate containers. |
protected ComponentRenderer<Panel> |
createDefaultRenderer() |
When you create a custom component, you need to implement this method and return a Renderer which is responsible
for taking care of sizing the component, rendering it and choosing where to place the cursor (if Interactable).
|
int |
getChildCount() |
Returns the number of children this container currently has
|
Collection<Component> |
getChildren() |
Returns collection that is to be considered a copy of the list of children contained inside of this object.
|
List<Component> |
getChildrenList() |
Returns list that is to be considered a copy of the list of children inside of this container.
|
TextColor |
getFillColorOverride() |
Returns the color used to override the default background color from the theme, if set.
|
LayoutManager |
getLayoutManager() |
Returns the layout manager assigned to this panel
|
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.
|
void |
invalidate() |
Marks the component as invalid and requiring to be re-drawn at next opportunity.
|
boolean |
isInvalid() |
Checks if this element (or any of its child components, if any) has signaled that what it's currently displaying
is out of date and needs re-drawing.
|
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.
|
Panel |
removeAllComponents() |
Removes all child components from this panel
|
boolean |
removeComponent(Component component) |
Removes the component from the container.
|
void |
setFillColorOverride(TextColor fillColor) |
Sets an override color to be used instead of the theme's color for Panels when drawing unused space.
|
Panel |
setLayoutManager(LayoutManager layoutManager) |
Assigns a new layout manager to this panel, replacing the previous layout manager assigned.
|
void |
updateLookupMap(InteractableLookupMap interactableLookupMap) |
Takes a lookup map and updates it with information about where all the interactables inside of this container
are located.
|
addTo, draw, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, isInside, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, toBasePane, toGlobal, withBorderaddTo, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, isInside, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, toBasePane, toGlobal, withBorderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdrawpublic Panel()
LinearLayout layout manager.public Panel(LayoutManager layoutManager)
public Panel addComponent(Component component)
component - Child component to add to this panelpublic Panel addComponent(int index, Component component)
component - Child component to add to this panelindex - At what index to add the component among the existing componentspublic Panel addComponent(Component component, LayoutData layoutData)
component.setLayoutData(layoutData);
panel.addComponent(component);
component - Component to add to the panellayoutData - Layout data to assign to the componentpublic boolean containsComponent(Component component)
Containertrue if this container contains the supplied component either directly or indirectly through
intermediate containers.containsComponent in interface Containercomponent - Component to check if it's part of this containertrue if the component is inside this Container, otherwise falsepublic boolean removeComponent(Component component)
ContainerremoveComponent in interface Containercomponent - Component to remove from the Containertrue if the component existed inside the container and was removed, false otherwisepublic Panel removeAllComponents()
public Panel setLayoutManager(LayoutManager layoutManager)
layoutManager - New layout manager this panel should be usingpublic TextColor getFillColorOverride()
null is
returned and whatever theme is assigned will be used to derive the fill color.public void setFillColorOverride(TextColor fillColor)
null, it will reset back to the theme's color.fillColor - Color to draw the unused space with instead of what the theme definition says, no null
to go back to the theme definitionpublic LayoutManager getLayoutManager()
public int getChildCount()
ContainergetChildCount in interface Containerpublic Collection<Component> getChildren()
Container
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.
getChildren in interface ContainerContainer.getChildrenList()public List<Component> getChildrenList()
ContainergetChildrenList in interface ContainerContainer.getChildren()protected ComponentRenderer<Panel> createDefaultRenderer()
AbstractComponentcreateDefaultRenderer in class AbstractComponent<Panel>public TerminalSize calculatePreferredSize()
AbstractComponentcalculatePreferredSize in class AbstractComponent<Panel>public boolean isInvalid()
TextGUIElementisInvalid in interface TextGUIElementisInvalid in class AbstractComponent<Panel>true if the component is invalid and needs redrawing, false otherwisepublic Interactable nextFocus(Interactable fromThis)
Containernull.public Interactable previousFocus(Interactable fromThis)
Containernull.previousFocus in interface ContainerfromThis - Component from which to get the previous interactable,
or if null, pick the last interactable in the listpublic boolean handleInput(KeyStroke key)
Containerfalse 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 return true, the event will stop here and won't be
reported as unhandled.handleInput in interface Containerkey - Keystroke that was ignored by the interactable inside this containertrue 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 onpublic void updateLookupMap(InteractableLookupMap interactableLookupMap)
ContainerupdateLookupMap in interface ContainerinteractableLookupMap - Interactable map to updatepublic void invalidate()
Componentinvalidate in interface Componentinvalidate in class AbstractComponent<Panel>Copyright © 2020. All rights reserved.