Class CheckBox
java.lang.Object
com.googlecode.lanterna.gui2.AbstractComponent<CheckBox>
com.googlecode.lanterna.gui2.AbstractInteractableComponent<CheckBox>
com.googlecode.lanterna.gui2.CheckBox
- All Implemented Interfaces:
Component, Interactable, TextGUIElement
The checkbox component looks like a regular checkbox that you can find in modern graphics user interfaces, a label
and a space that the user can toggle on and off by using enter or space keys.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHelper interface that doesn't add any new methods but makes coding new check box renderers a little bit more clearstatic classThe default renderer that is used unless overridden.static interfaceListener interface that can be used to catch user events on the check boxNested classes/interfaces inherited from interface Interactable
Interactable.FocusChangeDirection, Interactable.Result -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddListener(CheckBox.Listener listener) Adds a listener to this check box so that it will be notificed on certain user actionsprotected CheckBox.CheckBoxRendererWhen 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).getLabel()Returns the label of check boxhandleKeyStroke(KeyStroke keyStroke) This method can be overridden to handle various user input (mostly from the keyboard) when this component is in focus.booleanReturns the checked state of this check boxremoveListener(CheckBox.Listener listener) Removes a listener from this check box so that, if it was previously added, it will no long receive any eventssetChecked(boolean checked) Programmatically updated the check box to a particular checked stateUpdates the label of the checkboxMethods inherited from class AbstractInteractableComponent
afterEnterFocus, afterLeaveFocus, getCursorLocation, getInputFilter, getRenderer, handleInput, isActivationStroke, isEnabled, isFocusable, isFocused, isKeyboardActivationStroke, isMouseActivationStroke, isMouseDown, isMouseDrag, isMouseMove, isMouseUp, onEnterFocus, onLeaveFocus, setEnabled, setInputFilter, takeFocusMethods inherited from class AbstractComponent
addTo, calculatePreferredSize, draw, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isInvalid, isVisible, onAdded, onAfterDrawing, onBeforeDrawing, onRemoved, runOnGUIThreadIfExistsOtherwiseRunDirect, self, setLayoutData, setPosition, setPreferredSize, setRenderer, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
addTo, getBasePane, getGlobalPosition, getLayoutData, getParent, getPosition, getPreferredSize, getSize, getTextGUI, getTheme, getThemeDefinition, hasParent, invalidate, isInside, isVisible, onAdded, onRemoved, setLayoutData, setPosition, setPreferredSize, setSize, setTheme, setVisible, toBasePane, toGlobal, withBorderMethods inherited from interface TextGUIElement
draw, isInvalid
-
Field Details
-
listeners
-
label
-
checked
private boolean checked
-
-
Constructor Details
-
CheckBox
public CheckBox()Creates a new checkbox with no label, initially set to un-checked -
CheckBox
Creates a new checkbox with a specific label, initially set to un-checked- Parameters:
label- Label to assign to the check box
-
-
Method Details
-
setChecked
Programmatically updated the check box to a particular checked state- Parameters:
checked- Iftrue, the check box will be set to toggled on, otherwisefalse- Returns:
- Itself
-
isChecked
public boolean isChecked()Returns the checked state of this check box- Returns:
trueif the check box is toggled on, otherwisefalse
-
handleKeyStroke
Description copied from class:AbstractInteractableComponentThis method can be overridden to handle various user input (mostly from the keyboard) when this component is in focus. The input method from the interface,handleInput(..)is final inAbstractInteractableComponentto ensure the input filter is properly handled. If the filter decides that this event should be processed, it will call this method.- Overrides:
handleKeyStrokein classAbstractInteractableComponent<CheckBox>- Parameters:
keyStroke- What input was entered by the user- Returns:
- Result of processing the key-stroke
-
setLabel
-
getLabel
Returns the label of check box- Returns:
- Label currently assigned to the check box
-
addListener
Adds a listener to this check box so that it will be notificed on certain user actions- Parameters:
listener- Listener to fire events on- Returns:
- Itself
-
removeListener
Removes a listener from this check box so that, if it was previously added, it will no long receive any events- Parameters:
listener- Listener to remove from the check box- Returns:
- Itself
-
createDefaultRenderer
Description copied from class:AbstractComponentWhen 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). This value is intended to be overridden by custom themes.- Specified by:
createDefaultRendererin classAbstractInteractableComponent<CheckBox>- Returns:
- Renderer to use when sizing and drawing this component
-