public class Button extends AbstractInteractableComponent<Button>
Modifier and Type | Class and Description |
---|---|
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
|
Interactable.FocusChangeDirection, Interactable.Result
Constructor and Description |
---|
Button(String label)
Creates a new button with a specific label and no 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 and Description |
---|---|
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.
|
void |
setLabel(String label)
Updates the label on the button to the specified string
|
String |
toString() |
afterEnterFocus, afterLeaveFocus, getInputFilter, getRenderer, handleInput, isFocused, onEnterFocus, onLeaveFocus, setInputFilter, takeFocus
addTo, calculatePreferredSize, draw, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getRendererFromTheme, getSize, getTextGUI, hasParent, invalidate, isInside, isInvalid, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, toBasePane, toGlobal, withBorder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addTo, getBasePane, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, hasParent, invalidate, isInside, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, toBasePane, toGlobal, withBorder
draw, isInvalid
public Button(String label)
label
- Label to put on the buttonprotected Button.ButtonRenderer createDefaultRenderer()
AbstractComponent
createDefaultRenderer
in class AbstractInteractableComponent<Button>
public TerminalPosition getCursorLocation()
Interactable
getCursorLocation
in interface Interactable
getCursorLocation
in class AbstractInteractableComponent<Button>
public Interactable.Result handleKeyStroke(KeyStroke keyStroke)
AbstractInteractableComponent
handleInput(..)
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 userpublic final void setLabel(String label)
label
- New label to use on the buttonpublic String getLabel()
Copyright © 2016. All rights reserved.