Package xyz.gmitch215.socketmc.screen.ui
Class FocusedTextWidget
java.lang.Object
xyz.gmitch215.socketmc.screen.ui.AbstractWidget
xyz.gmitch215.socketmc.screen.ui.AbstractTextWidget
xyz.gmitch215.socketmc.screen.ui.FocusedTextWidget
- All Implemented Interfaces:
Serializable
,LayoutElement
,Positionable
Represents a focusable text widget that displays a text message.
AbstractWidget.getWidth()
serves as the text's maximum width. AbstractWidget.getHeight()
is ignored.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default padding around text elements. -
Constructor Summary
ConstructorDescriptionFocusedTextWidget
(int x, int y, int width, int height, @NotNull String messageJSON, boolean alwaysShowBorder, int padding) Constructs a new text widget.FocusedTextWidget
(int x, int y, int width, int height, @NotNull Text message) Constructs a new text widget.FocusedTextWidget
(int x, int y, int width, int height, @NotNull Text message, boolean alwaysShowBorder) Constructs a new text widget with the default padding.FocusedTextWidget
(int x, int y, int width, int height, @NotNull Text message, boolean alwaysShowBorder, int padding) Constructs a new text widget.FocusedTextWidget
(@NotNull ElementBounds bounds, @NotNull Text message) Constructs a new text widget with the default padding.FocusedTextWidget
(@NotNull ElementBounds bounds, @NotNull Text message, boolean alwaysShowBorder) Constructs a new text widget with the default padding.FocusedTextWidget
(@NotNull ElementBounds bounds, @NotNull Text message, boolean alwaysShowBorder, int padding) Constructs a new text widget. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the padding around the text.boolean
Gets whether this text widget should always show its border.void
setAlwaysShowBorder
(boolean alwaysShowBorder) Sets whether this text widget should always show its border.void
setPadding
(int padding) Sets the padding around the text.Methods inherited from class xyz.gmitch215.socketmc.screen.ui.AbstractTextWidget
equals, getMessageJSON, setMessage, setMessageJSON
Methods inherited from class xyz.gmitch215.socketmc.screen.ui.AbstractWidget
clearListeners, getHeight, getListeners, getTooltip, getWidth, getX, getY, hashCode, onClick, setHeight, setTooltip, setWidth, setX, setY, toString, visitWidgets
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface xyz.gmitch215.socketmc.screen.layout.LayoutElement
setPosition, setSize, setSize, setSize
Methods inherited from interface xyz.gmitch215.socketmc.screen.Positionable
inSamePosition
-
Field Details
-
DEFAULT_PADDING
public static final int DEFAULT_PADDINGThe default padding around text elements.- See Also:
-
-
Constructor Details
-
FocusedTextWidget
public FocusedTextWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Text message) throws IllegalArgumentException Constructs a new text widget with the default padding.- Parameters:
bounds
- the boundsmessage
- the text message- Throws:
IllegalArgumentException
- if message is null
-
FocusedTextWidget
public FocusedTextWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Text message, boolean alwaysShowBorder) throws IllegalArgumentException Constructs a new text widget with the default padding.- Parameters:
bounds
- the boundsmessage
- the text messagealwaysShowBorder
- whether to render a drop shadow- Throws:
IllegalArgumentException
- if message is null
-
FocusedTextWidget
public FocusedTextWidget(@NotNull @NotNull ElementBounds bounds, @NotNull @NotNull Text message, boolean alwaysShowBorder, int padding) throws IllegalArgumentException Constructs a new text widget.- Parameters:
bounds
- the boundsmessage
- the text messagealwaysShowBorder
- whether to render a drop shadowpadding
- the padding around the text- Throws:
IllegalArgumentException
- if padding is negative or message is null
-
FocusedTextWidget
Constructs a new text widget.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightmessage
- the text message- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or message is null
-
FocusedTextWidget
public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull Text message, boolean alwaysShowBorder) Constructs a new text widget with the default padding.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightmessage
- the text messagealwaysShowBorder
- whether to render a drop shadow- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or message is null
-
FocusedTextWidget
public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull Text message, boolean alwaysShowBorder, int padding) throws IllegalArgumentException Constructs a new text widget.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightmessage
- the text messagealwaysShowBorder
- whether to render a drop shadowpadding
- the padding around the text- Throws:
IllegalArgumentException
- if coordinates, dimensions, or padding are negative, or message is null
-
FocusedTextWidget
public FocusedTextWidget(int x, int y, int width, int height, @NotNull @NotNull String messageJSON, boolean alwaysShowBorder, int padding) throws IllegalArgumentException Constructs a new text widget.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightmessageJSON
- the text message as a JSON stringalwaysShowBorder
- whether to render a drop shadowpadding
- the padding around the text- Throws:
IllegalArgumentException
- if coordinates, dimensions, or padding are negative, or message is null
-
-
Method Details
-
isAlwaysShowBorder
public boolean isAlwaysShowBorder()Gets whether this text widget should always show its border.- Returns:
- Whether to always show the border
-
setAlwaysShowBorder
public void setAlwaysShowBorder(boolean alwaysShowBorder) Sets whether this text widget should always show its border.- Parameters:
alwaysShowBorder
- Whether to always show the border
-
getPadding
public int getPadding()Gets the padding around the text.- Returns:
- Text Padding
-
setPadding
public void setPadding(int padding) Sets the padding around the text.- Parameters:
padding
- Text Padding
-