Package xyz.gmitch215.socketmc.screen.ui
Class ImageButton
java.lang.Object
xyz.gmitch215.socketmc.screen.ui.AbstractWidget
xyz.gmitch215.socketmc.screen.ui.AbstractTextWidget
xyz.gmitch215.socketmc.screen.ui.AbstractButton
xyz.gmitch215.socketmc.screen.ui.ImageButton
- All Implemented Interfaces:
Serializable
,LayoutElement
,Positionable
Represents a button that displays an image.
- See Also:
-
Field Summary
Fields inherited from class xyz.gmitch215.socketmc.screen.ui.AbstractButton
BIG_WIDTH, DEFAULT_HEIGHT, DEFAULT_SPACING, DEFAULT_WIDTH, SMALL_WIDTH
Fields inherited from class xyz.gmitch215.socketmc.screen.ui.AbstractWidget
DEFAULT_PADDING, height, tooltip, width, x, y
-
Constructor Summary
ConstructorDescriptionImageButton
(int x, int y, int width, int height, @NotNull Sprite sprite) Constructs a new button with an empty message.ImageButton
(int x, int y, int width, int height, @NotNull Sprite sprite, @NotNull String messageJSON) Constructs a new button.ImageButton
(int x, int y, int width, int height, @NotNull Sprite sprite, @NotNull Text message) Constructs a new button.ImageButton
(int x, int y, @NotNull Sprite sprite) Constructs a new button using the default dimesions and an empty message.ImageButton
(int x, int y, @NotNull Sprite sprite, @NotNull Text message) Constructs a new button using the default dimesions. -
Method Summary
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
-
Constructor Details
-
ImageButton
Constructs a new button using the default dimesions and an empty message.- Parameters:
x
- the x-coordinatey
- the y-coordinatesprite
- the sprite- Throws:
IllegalArgumentException
- if coordinates are negative, or sprite is null
-
ImageButton
public ImageButton(int x, int y, int width, int height, @NotNull @NotNull Sprite sprite) throws IllegalArgumentException Constructs a new button with an empty message.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightsprite
- the sprite- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or sprite is null
-
ImageButton
public ImageButton(int x, int y, @NotNull @NotNull Sprite sprite, @NotNull @NotNull Text message) throws IllegalArgumentException Constructs a new button using the default dimesions.- Parameters:
x
- the x-coordinatey
- the y-coordinatesprite
- the spritemessage
- the message- Throws:
IllegalArgumentException
- if coordinates are negative, or message/sprite is null
-
ImageButton
public ImageButton(int x, int y, int width, int height, @NotNull @NotNull Sprite sprite, @NotNull @NotNull Text message) throws IllegalArgumentException Constructs a new button.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightsprite
- the spritemessage
- the message- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or sprite is null
-
ImageButton
public ImageButton(int x, int y, int width, int height, @NotNull @NotNull Sprite sprite, @NotNull @NotNull String messageJSON) throws IllegalArgumentException Constructs a new button.- Parameters:
x
- the x-coordinatey
- the y-coordinatewidth
- the widthheight
- the heightsprite
- the spritemessageJSON
- the message in JSON format- Throws:
IllegalArgumentException
- if coordinates or dimensions are negative, or sprite is null
-
-
Method Details
-
getSprite
Gets the sprite for this button.- Returns:
- the sprite
-
setSprite
Sets the sprite for this button.- Parameters:
sprite
- the sprite- Throws:
IllegalArgumentException
- if sprite is null
-