Component, Interactable, TextGUIElementpublic class Button extends AbstractInteractableComponent<Button>
addListener(Listener). To remove a previously attached action, use
removeListener(Listener).| Modifier and Type | Class | Description |
|---|---|---|
static class |
Button.BorderedButtonRenderer |
|
static interface |
Button.ButtonRenderer |
Helper interface that doesn't add any new methods but makes coding new button renderers a little bit more clear
|
static class |
Button.DefaultButtonRenderer |
This is the default button renderer that is used if you don't override anything.
|
static class |
Button.FlatButtonRenderer |
Alternative button renderer that displays buttons with just the label and minimal decoration
|
static interface |
Button.Listener |
Listener interface that can be used to catch user events on the button
|
Interactable.FocusChangeDirection, Interactable.Result| Constructor | Description |
|---|---|
Button(String label) |
Creates a new button with a specific label and no initially attached action.
|
Button(String label,
Runnable action) |
Creates a new button with a label and an associated action to fire when triggered by the user
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addListener(Button.Listener listener) |
Adds a listener to notify when the button is triggered; the listeners will be called serially in the order they
were added
|
protected Button.ButtonRenderer |
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).
|
TerminalPosition |
getCursorLocation() |
Returns, in local coordinates, where to put the cursor on the screen when this component has focus.
|
String |
getLabel() |
Returns the label current assigned to the button
|
Interactable.Result |
handleKeyStroke(KeyStroke keyStroke) |
This method can be overridden to handle various user input (mostly from the keyboard) when this component is in
focus.
|
boolean |
removeListener(Button.Listener listener) |
Removes a listener from the button's list of listeners to call when the button is triggered.
|
void |
setLabel(String label) |
Updates the label on the button to the specified string
|
String |
toString() |
|
protected void |
triggerActions() |
addTo, calculatePreferredSize, draw, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, toBasePane, toGlobal, withBorderafterEnterFocus, afterLeaveFocus, getInputFilter, getRenderer, handleInput, isEnabled, isFocusable, isFocused, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocusaddTo, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, toBasePane, toGlobal, withBorderclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdraw, isInvalidpublic Button(String label)
label - Label to put on the buttonprotected Button.ButtonRenderer createDefaultRenderer()
AbstractComponentcreateDefaultRenderer in class AbstractInteractableComponent<Button>public TerminalPosition getCursorLocation()
InteractablegetCursorLocation in interface InteractablegetCursorLocation in class AbstractInteractableComponent<Button>public Interactable.Result handleKeyStroke(KeyStroke keyStroke)
AbstractInteractableComponenthandleInput(..) is final in
AbstractInteractableComponent to ensure the input filter is properly handled. If the filter decides that
this event should be processed, it will call this method.handleKeyStroke in class AbstractInteractableComponent<Button>keyStroke - What input was entered by the userprotected void triggerActions()
public final void setLabel(String label)
label - New label to use on the buttonpublic void addListener(Button.Listener listener)
listener - Listener to call when the button is triggeredpublic boolean removeListener(Button.Listener listener)
listener - Listener to remove from this button's listener listtrue if this button contained the specified listenerpublic String getLabel()
Copyright © 2020. All rights reserved.