JTerminal documentation Help

Button

The ButtonComponent class makes it possible to add your own labeled elements to the user interface and equip them with an action event. The button is selectable and can be controlled by tab, arrow keys or mouse input.

ButtonComponent buttonComponent = new ButtonComponent(); buttonComponent.text("I am Button"); buttonComponent.action(() -> { //... });
button unselected
button selected

Methods

Method

Description

int preferredWidth()

Returns the recommended width

String text()

Returns the name

void text(String)

Sets the name and adjust the size

Runnable action()

Returns the action event

void action(Runnable)

Sets the action event

Events

ButtonClickedEvent

Event is sent on interaction with button.

buttonComponent.eventBus().subscribe(ButtonClickedEvent.class, event -> { //... });
    Last modified: 01 Juni 2025