Component
, Container
, TextGUIElement
public class MenuBar extends AbstractComponent<MenuBar> implements Container
Window
by using the
Window.setMenuBar(MenuBar)
method, then use add(Menu)
to add sub-menus to the menu bar.Modifier and Type | Class | Description |
---|---|---|
class |
MenuBar.DefaultMenuBarRenderer |
The default implementation for rendering a
MenuBar |
Constructor | Description |
---|---|
MenuBar() |
Creates a new menu bar
|
Modifier and Type | Method | Description |
---|---|---|
MenuBar |
add(Menu menu) |
Adds a new drop-down menu to the menu bar, at the end
|
boolean |
containsComponent(Component component) |
Returns
true if this container contains the supplied component either directly or indirectly through
intermediate containers. |
protected ComponentRenderer<MenuBar> |
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.
|
Menu |
getMenu(int index) |
Returns the drop-down menu at the specified index.
|
int |
getMenuCount() |
Returns the number of menus this menu bar currently has
|
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.
|
boolean |
isEmptyMenuBar() |
|
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.
|
TerminalPosition |
toBasePane(TerminalPosition position) |
Translates a position local to the container to the base pane's coordinate space.
|
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, calculatePreferredSize, draw, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, isVisible, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, setVisible, toGlobal, withBorder
addTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getRenderer, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toGlobal, withBorder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
draw, isInvalid
public MenuBar add(Menu menu)
menu
- Menu to add to the menu barpublic int getChildCount()
Container
getChildCount
in interface Container
public List<Component> getChildrenList()
Container
getChildrenList
in interface Container
Container.getChildren()
public 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 Container
Container.getChildrenList()
public boolean containsComponent(Component component)
Container
true
if this container contains the supplied component either directly or indirectly through
intermediate containers.containsComponent
in interface Container
component
- Component to check if it's part of this containertrue
if the component is inside this Container, otherwise false
public boolean removeComponent(Component component)
Container
removeComponent
in interface Container
component
- Component to remove from the Containertrue
if the component existed inside the container and was removed, false
otherwisepublic Interactable nextFocus(Interactable fromThis)
Container
null
.public Interactable previousFocus(Interactable fromThis)
Container
null
.previousFocus
in interface Container
fromThis
- Component from which to get the previous interactable,
or if null, pick the last interactable in the listpublic boolean handleInput(KeyStroke key)
Container
false
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 Container
key
- 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 Menu getMenu(int index)
index
- Index of the menu to returnIndexOutOfBoundsException
- if the index is out of rangepublic int getMenuCount()
protected ComponentRenderer<MenuBar> createDefaultRenderer()
AbstractComponent
createDefaultRenderer
in class AbstractComponent<MenuBar>
public void updateLookupMap(InteractableLookupMap interactableLookupMap)
Container
updateLookupMap
in interface Container
interactableLookupMap
- Interactable map to updatepublic TerminalPosition toBasePane(TerminalPosition position)
Component
null
.toBasePane
in interface Component
toBasePane
in class AbstractComponent<MenuBar>
position
- Position to translate (relative to the container's top-left corner)null
if the component is an orphanpublic boolean isEmptyMenuBar()
Copyright © 2020. All rights reserved.