Skip to content
stefvanschie edited this page Dec 19, 2022 · 4 revisions

Languages: Dutch (Nederlands)

A toggle button switches between two different states: enabled and disabled (these can, however, be interpreted as you like such as on/off, yes/no, etc.). These two states are toggled by clicking on the button.

To create such a toggle button you invoke its constructor:

ToggleButton toggleButton = new ToggleButton(0, 0, 9, 6);

You can also toggle between these options, if you wish to do so, programmatically by invoking the toggle method.

toggleButton.toggle();

To view whether the toggle button is currently enabled or disabled, you can call isEnabled, which returns true if the button is enabled and false if it is not.

boolean enabled = toggleButton.isEnabled();

You can also prevent the player from using the button by calling allowToggle.

toggleButton.allowToggle(false);

XML

Everything from Panes also applies here.

Creating a toggle button can be done with togglebutton.

<togglebutton x="0" y="0" length="9" height="6"/>

Optional attributes

You can specify the default state with the enabled attribute and setting it to either true or false.

<togglebutton x="0" y="0" length="9" height="6" enabled="true"/>
Clone this wiki locally