Class ButtonWidget


public class ButtonWidget extends PanelWidget
A class representing a ButtonWidget, which is a type of PanelWidget.
  • Constructor Details

    • ButtonWidget

      public ButtonWidget(String text, int x, int y, int width, int height, int borderRadius, NanoColor backgroundColor, Runnable onClickMethod)
      Constructs a new ButtonWidget with the specified text, position, size, border radius, and background color.
      Parameters:
      text - text displayed on the button
      x - the X-coordinate of the Widget's position
      y - the Y-coordinate of the Widget's position
      width - the width of the widget
      height - the height of the widget
      borderRadius - the radius of the corner rounding in pixels
      backgroundColor - the background color of the widget, specified in NanoColor
      onClickMethod - method that is called when the button is clicked
  • Method Details

    • getTextColor

      public final NanoColor getTextColor()
      Returns the text color of the ButtonWidget.
      Returns:
      the text color
    • setTextColor

      public final void setTextColor(NanoColor textColor)
      Sets the text color of the ButtonWidget.
      Parameters:
      textColor - the text color to set
    • getText

      public final String getText()
      Returns the text of the ButtonWidget.
      Returns:
      the text
    • setText

      public final void setText(String text)
      Sets the text of the ButtonWidget.
      Parameters:
      text - the text to set
    • getFontSize

      public final int getFontSize()
      Returns the font size of the ButtonWidget.
      Returns:
      the font size
    • setFontSize

      public final void setFontSize(int fontSize)
      Sets the font size of the ButtonWidget.
      Parameters:
      fontSize - the font size to set
    • getFontName

      public final String getFontName()
      Returns the font name of the ButtonWidget.
      Returns:
      the font name
    • setFontName

      public final void setFontName(String fontName)
      Sets the font name of the ButtonWidget.
      Parameters:
      fontName - the font name to set
    • setOnClickMethod

      public final void setOnClickMethod(Runnable onClickMethod)
      Sets the method to be called when the ButtonWidget is clicked.
      Parameters:
      onClickMethod - the method to set
    • isEnable

      public final boolean isEnable()
      Returns whether the ButtonWidget is enabled.
      Returns:
      true if the button is enabled, false otherwise
    • setEnable

      public final void setEnable(boolean enable)
      Sets whether the ButtonWidget 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 the Widget.
      Overrides:
      onLeftMouseUp in class PanelWidget
      Parameters:
      x - relative x-coordinate of the mouse position
      y - relative y-coordinate of the mouse position
    • render

      public void render()
      Renders the Widget
      Overrides:
      render in class PanelWidget