Package com.avrix.ui.widgets
Class ButtonWidget
java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.PanelWidget
com.avrix.ui.widgets.ButtonWidget
A class representing a
ButtonWidget
, which is a type of PanelWidget
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionButtonWidget
(String text, int x, int y, int width, int height, int borderRadius, NanoColor backgroundColor, Runnable onClickMethod) Constructs a newButtonWidget
with the specified text, position, size, border radius, and background color. -
Method Summary
Modifier and TypeMethodDescriptionfinal String
Returns the font name of theButtonWidget
.final int
Returns the font size of theButtonWidget
.final String
getText()
Returns the text of theButtonWidget
.final NanoColor
Returns the text color of theButtonWidget
.final boolean
isEnable()
Returns whether theButtonWidget
is enabled.void
onLeftMouseUp
(int x, int y) Called when the left mouse button is released over theWidget
.void
render()
Renders theWidget
final void
setEnable
(boolean enable) Sets whether theButtonWidget
is enabled.final void
setFontName
(String fontName) Sets the font name of theButtonWidget
.final void
setFontSize
(int fontSize) Sets the font size of theButtonWidget
.final void
setOnClickMethod
(Runnable onClickMethod) Sets the method to be called when theButtonWidget
is clicked.final void
Sets the text of theButtonWidget
.final void
setTextColor
(NanoColor textColor) Sets the text color of theButtonWidget
.Methods inherited from class com.avrix.ui.widgets.PanelWidget
isDraggable, onLeftMouseDown, onLeftMouseUpOutside, postRender, setBackgroundColor, setBorderColor, setBorderRadius, setBorderWidth, setDraggable, setDrawBorder, update
Methods inherited from class com.avrix.ui.widgets.Widget
addChild, addToScreen, bringToTop, drawArc, drawArc, drawCircle, drawEllipse, drawImage, drawLine, drawRect, drawRectOutline, drawRoundedRect, drawRoundedRectOutline, drawText, getAbsoluteParent, getChildren, getHeight, getMaxScrollX, getMaxScrollY, getParent, getScrollSpeed, getScrollX, getScrollY, getWidth, getX, getXA, getY, getYA, intersectScissor, isAlwaysOnTop, isHovered, isPointOver, isScrollable, isScrollLock, isVisible, isVisibleWithinParent, isVisibleWithinWindow, onInitialize, onKeyPress, onKeyRelease, onKeyRepeat, onLeftMouseDownOutside, onMouseEnter, onMouseExit, onMouseMove, onMouseMoveOutside, onMouseWheel, onRightMouseDown, onRightMouseDownOutside, onRightMouseUp, onRightMouseUpOutside, preRender, removeChild, removeFromScreen, renderChildren, setAlwaysOnTop, setHeight, setMaxScrollX, setMaxScrollY, setScrollable, setScrollLock, setScrollSpeed, setScrollX, setScrollY, setVisible, setWidth, setX, setXA, setY, setYA
-
Constructor Details
-
ButtonWidget
public ButtonWidget(String text, int x, int y, int width, int height, int borderRadius, NanoColor backgroundColor, Runnable onClickMethod) Constructs a newButtonWidget
with the specified text, position, size, border radius, and background color.- Parameters:
text
- text displayed on the buttonx
- the X-coordinate of theWidget
's positiony
- the Y-coordinate of theWidget
's positionwidth
- the width of the widgetheight
- the height of the widgetborderRadius
- the radius of the corner rounding in pixelsbackgroundColor
- the background color of the widget, specified inNanoColor
onClickMethod
- method that is called when the button is clicked
-
-
Method Details
-
getTextColor
Returns the text color of theButtonWidget
.- Returns:
- the text color
-
setTextColor
Sets the text color of theButtonWidget
.- Parameters:
textColor
- the text color to set
-
getText
Returns the text of theButtonWidget
.- Returns:
- the text
-
setText
Sets the text of theButtonWidget
.- Parameters:
text
- the text to set
-
getFontSize
public final int getFontSize()Returns the font size of theButtonWidget
.- Returns:
- the font size
-
setFontSize
public final void setFontSize(int fontSize) Sets the font size of theButtonWidget
.- Parameters:
fontSize
- the font size to set
-
getFontName
Returns the font name of theButtonWidget
.- Returns:
- the font name
-
setFontName
Sets the font name of theButtonWidget
.- Parameters:
fontName
- the font name to set
-
setOnClickMethod
Sets the method to be called when theButtonWidget
is clicked.- Parameters:
onClickMethod
- the method to set
-
isEnable
public final boolean isEnable()Returns whether theButtonWidget
is enabled.- Returns:
- true if the button is enabled, false otherwise
-
setEnable
public final void setEnable(boolean enable) Sets whether theButtonWidget
is enabled.- Parameters:
enable
- true to enable the button, false to disable it
-
onLeftMouseUp
public void onLeftMouseUp(int x, int y) Called when the left mouse button is released over theWidget
.- Overrides:
onLeftMouseUp
in classPanelWidget
- Parameters:
x
- relative x-coordinate of the mouse positiony
- relative y-coordinate of the mouse position
-
render
public void render()Renders theWidget
- Overrides:
render
in classPanelWidget
-