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
ConstructorsConstructorDescriptionButtonWidget(String text, int x, int y, int width, int height, int borderRadius, NanoColor backgroundColor, Runnable onClickMethod) Constructs a newButtonWidgetwith the specified text, position, size, border radius, and background color. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringReturns the font name of theButtonWidget.final intReturns the font size of theButtonWidget.final StringgetText()Returns the text of theButtonWidget.final NanoColorReturns the text color of theButtonWidget.final booleanisEnable()Returns whether theButtonWidgetis enabled.voidonLeftMouseUp(int x, int y) Called when the left mouse button is released over theWidget.voidrender()Renders theWidgetfinal voidsetEnable(boolean enable) Sets whether theButtonWidgetis enabled.final voidsetFontName(String fontName) Sets the font name of theButtonWidget.final voidsetFontSize(int fontSize) Sets the font size of theButtonWidget.final voidsetOnClickMethod(Runnable onClickMethod) Sets the method to be called when theButtonWidgetis clicked.final voidSets the text of theButtonWidget.final voidsetTextColor(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, updateMethods 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 newButtonWidgetwith 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 inNanoColoronClickMethod- 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 theButtonWidgetis clicked.- Parameters:
onClickMethod- the method to set
-
isEnable
public final boolean isEnable()Returns whether theButtonWidgetis enabled.- Returns:
- true if the button is enabled, false otherwise
-
setEnable
public final void setEnable(boolean enable) Sets whether theButtonWidgetis 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:
onLeftMouseUpin classPanelWidget- Parameters:
x- relative x-coordinate of the mouse positiony- relative y-coordinate of the mouse position
-
render
public void render()Renders theWidget- Overrides:
renderin classPanelWidget
-