public class WLabel extends WWidget
| Modifier and Type | Field and Description |
|---|---|
protected int |
color |
protected int |
darkmodeColor |
static int |
DEFAULT_DARKMODE_TEXT_COLOR
The default text color for dark mode labels.
|
static int |
DEFAULT_TEXT_COLOR
The default text color for light mode labels.
|
protected HorizontalAlignment |
horizontalAlignment |
protected net.minecraft.text.Text |
text |
protected VerticalAlignment |
verticalAlignment |
| Constructor and Description |
|---|
WLabel(java.lang.String text)
Constructs a new label with the default text color.
|
WLabel(java.lang.String text,
int color)
Constructs a new label.
|
WLabel(net.minecraft.text.Text text)
Constructs a new label with the default text color.
|
WLabel(net.minecraft.text.Text text,
int color)
Constructs a new label.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canResize()
Checks whether this widget can be resized using
WWidget.setSize(int, int). |
WLabel |
disableDarkmode()
Disables separate dark mode coloring by copying the dark color to be the light color.
|
int |
getColor()
Gets the light mode color of this label.
|
int |
getDarkmodeColor()
Gets the dark mode color of this label.
|
HorizontalAlignment |
getHorizontalAlignment()
Gets the horizontal text alignment of this label.
|
net.minecraft.text.Text |
getText()
Gets the text of this label.
|
@Nullable net.minecraft.text.Style |
getTextStyleAt(int x,
int y)
Gets the text style at the specific widget-space coordinates.
|
VerticalAlignment |
getVerticalAlignment()
Gets the vertical text alignment of this label.
|
InputResult |
onClick(int x,
int y,
int button)
Notifies this widget that the mouse has been pressed and released, both while inside its bounds.
|
void |
paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
Paints this widget.
|
WLabel |
setColor(int color)
Sets the light mode color of this label.
|
WLabel |
setColor(int color,
int darkmodeColor)
Sets the light and dark mode colors of this label.
|
WLabel |
setDarkmodeColor(int color)
Sets the dark mode color of this label.
|
WLabel |
setHorizontalAlignment(HorizontalAlignment align)
Sets the horizontal text alignment of this label.
|
void |
setSize(int x,
int y)
Sets the size of this widget.
|
WLabel |
setText(net.minecraft.text.Text text)
Sets the text of this label.
|
WLabel |
setVerticalAlignment(VerticalAlignment align)
Sets the vertical text alignment of this label.
|
addPainters, addTooltip, canFocus, createPeers, cycleFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, hit, isActivationKey, isFocused, isWithinBounds, onCharTyped, onFocusGained, onFocusLost, onHidden, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setLocation, setParent, tick, validateprotected net.minecraft.text.Text text
protected HorizontalAlignment horizontalAlignment
protected VerticalAlignment verticalAlignment
protected int color
protected int darkmodeColor
public static final int DEFAULT_TEXT_COLOR
public static final int DEFAULT_DARKMODE_TEXT_COLOR
public WLabel(java.lang.String text,
int color)
text - the text of the labelcolor - the color of the labelpublic WLabel(net.minecraft.text.Text text,
int color)
text - the text of the labelcolor - the color of the labelpublic WLabel(java.lang.String text)
text - the text of the labelpublic WLabel(net.minecraft.text.Text text)
text - the text of the label@Environment(value=CLIENT)
public void paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
WWidget@Environment(value=CLIENT) public InputResult onClick(int x, int y, int button)
WWidgetonClick in class WWidgetx - The X coordinate of the event, in widget-space (0 is the left edge of this widget)y - The Y coordinate of the event, in widget-space (0 is the top edge of this widget)button - The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click)InputResult.PROCESSED if the event is handled, InputResult.IGNORED otherwise.@Environment(value=CLIENT)
@Nullable
public @Nullable net.minecraft.text.Style getTextStyleAt(int x,
int y)
x - the X coordinate in widget spacey - the Y coordinate in widget spacepublic boolean canResize()
WWidgetWWidget.setSize(int, int).public void setSize(int x,
int y)
WWidgetOverriding methods may restrict one of the dimensions to be
a constant value, for example super.setSize(x, 20).
public int getDarkmodeColor()
public WLabel setDarkmodeColor(int color)
color - the new colorpublic WLabel disableDarkmode()
public int getColor()
public WLabel setColor(int color)
color - the new colorpublic WLabel setColor(int color, int darkmodeColor)
color - the new light colordarkmodeColor - the new dark colorpublic net.minecraft.text.Text getText()
public WLabel setText(net.minecraft.text.Text text)
text - the new textpublic HorizontalAlignment getHorizontalAlignment()
public WLabel setHorizontalAlignment(HorizontalAlignment align)
align - the new text alignmentpublic VerticalAlignment getVerticalAlignment()
public WLabel setVerticalAlignment(VerticalAlignment align)
align - the new text alignment