API Reference
This page summarizes the commonly used public methods.
SSGL
| Method | Description |
|---|---|
SSGL.create(String) |
Creates a GUI with a literal title |
SSGL.create(Component) |
Creates a GUI with a component title |
SSGL.id(String) |
Creates an identifier in the ssgl namespace |
Gui
| Method | Description |
|---|---|
add(GuiElement) |
Adds an element |
add(GuiLayout) |
Adds a layout |
add(GuiScrollArea) |
Adds a scroll area |
label(String) |
Adds a label |
label(Component) |
Adds a label using a component |
button(String, Runnable) |
Adds a button |
button(Component, Runnable) |
Adds a button using a component |
contentWidth(int) |
Sets the preferred content width |
spacing(int) |
Sets root-element spacing |
boldTitle(boolean) |
Controls title boldness |
clear() |
Removes root elements |
open(boolean) |
Opens the GUI and determines whether it pauses singleplayer gameplay |
close() |
Closes the GUI and restores the previous screen |
GuiElement
| Component | Factory |
|---|---|
| Button | button(String, Runnable) |
| Button | button(Component, Runnable) |
| Label | label(String) |
| Label | label(Component) |
| Toggle | toggle(String, GuiValue<Boolean>) |
| Toggle | toggle(Component, GuiValue<Boolean>) |
| Slider | slider(String, double, double, GuiValue<Double>) |
| Slider | slider(Component, double, double, GuiValue<Double>) |
| Stepped slider | slider(String, double, double, double, GuiValue<Double>) |
| Stepped slider | slider(Component, double, double, double, GuiValue<Double>) |
| Text field | textField(String, GuiValue<String>) |
| Text field | textField(String, String, GuiValue<String>) |
| Text field | textField(Component, Component, GuiValue<String>) |
| Integer field | integerField(String, GuiValue<Integer>) |
| Integer field | integerField(String, String, GuiValue<Integer>) |
| Integer field | integerField(Component, Component, GuiValue<Integer>) |
| Decimal field | doubleField(String, GuiValue<Double>) |
| Decimal field | doubleField(String, String, GuiValue<Double>) |
| Decimal field | doubleField(Component, Component, GuiValue<Double>) |
| Image button | imageButton(Identifier, Runnable) |
| Empty image button | imageButton(Runnable) |
| Dynamic image | dynamicImageButton(...) |
Image buttons also have custom-size and tooltip overloads. See the Image Buttons page for their parameters and examples.
Additional element configuration:
| Method | Description |
|---|---|
width(int) |
Sets the preferred width |
height(int) |
Sets the height, subject to the component's minimum |
align(Alignment) |
Sets horizontal alignment |
GuiLayout
| Method | Description |
|---|---|
vertical() |
Creates a vertical layout |
horizontal() |
Creates a horizontal layout |
gap(int) |
Sets spacing between children |
add(GuiElement) |
Adds an element |
add(GuiLayout) |
Adds a nested layout |
add(GuiScrollArea) |
Adds a scroll area |
GuiScrollArea
| Method | Description |
|---|---|
vertical(int) |
Creates a vertical scroll area with a preferred viewport height |
gap(int) |
Sets spacing between children |
add(GuiElement) |
Adds an element |
add(GuiLayout) |
Adds a nested layout |
add(GuiScrollArea) |
Adds a nested scroll area |
GuiValue
| Method | Description |
|---|---|
of(T) |
Creates a value holder |
get() |
Reads the current value |
set(T) |
Changes the value |
onChange(Consumer<T>) |
Registers a permanent change listener |
subscribe(Consumer<T>) |
Registers a removable listener |
The removable listener returns a GuiValue.Subscription, which can be closed with close().
Alignment
| Value | Description |
|---|---|
Alignment.LEFT |
Left alignment |
Alignment.CENTER |
Center alignment |
Alignment.RIGHT |
Right alignment |
Compatibility
The following methods are retained for compatibility but are deprecated:
| Deprecated method | Replacement |
|---|---|
GuiElement.checkbox(...) |
GuiElement.toggle(...) |
GuiLayout.scrollable(int) |
GuiScrollArea.vertical(int) |
New integrations should use the replacement methods.