Skip to content

LabelWidget ​

Image title

LabelWidget is used to display text and component.

Advanced Widget

LabelWidget is a light-weight widget to display text only. text height, align, ... are fixed. Therefore, we reconmend to use the TextTextureWidget instead, which provids advanced controll of text display.

Basic Properties ​

FieldDescription
colorThe text color as an integer
dropShadowIndicates whether the drop shadow effect is enabled
lastTextValuecurrently text read only

APIs ​

setText() ​

Updates the label text with a string.

java
label.setText("New Label Text");

setComponent() ​

Same as setText() but support component as input


setTextProvider() ​

Configures a supplier to dynamically provide the label text. It will obtain the latest text per tick.

java
label.setTextProvider(() -> "Dynamic Text");

setColor() ​

Sets the text color. If a rich text component is already set, its style will be replaced accordingly.

java
label.setColor(0xFFFFFFFF); // ARGB

setDropShadow() ​

Enables or disables the drop shadow effect for the label.

java
label.setDropShadow(true);

Released under the MIT License.