Class ImageButton

  • All Implemented Interfaces:
    Clickable

    public class ImageButton
    extends ImageWidget
    implements Clickable
    An image button is a widget that displays an image and reacts to click events.
    • Constructor Detail

      • ImageButton

        public ImageButton​(String imagePath)
        Creates an image button with the resource path of the image to display.
        Parameters:
        imagePath - the resource path of the image to display.
      • ImageButton

        public ImageButton​(String imagePath,
                           ResourceImage.OutputFormat outputFormat)
        Creates an image button with the resource path and the output format of the image to display.
        Parameters:
        imagePath - the resource path of the image to display.
        outputFormat - the output format of the image to display.
    • Method Detail

      • setOnClickListener

        public void setOnClickListener​(@Nullable
                                       OnClickListener listener)
        Sets the listener on the click events of this button.
        Parameters:
        listener - the listener to set.
      • isInState

        public boolean isInState​(int state)
        Description copied from class: Widget
        Gets whether or not the widget is in the given state.
        Overrides:
        isInState in class Widget
        Parameters:
        state - the state to check.
        Returns:
        true if the widget is in the given state, false otherwise.
      • handleEvent

        public boolean handleEvent​(int event)
        Description copied from class: Widget
        Handles the given event. Does nothing by default and returns false (does not consume event).

        Called by the desktop event manager.

        Overrides:
        handleEvent in class Widget
        Parameters:
        event - the event to handle.
        Returns:
        true if the widget has consumed the event, false otherwise.
      • setPressed

        public void setPressed​(boolean pressed)
        Description copied from interface: Clickable
        Changes the clickable element state.
        Specified by:
        setPressed in interface Clickable
        Parameters:
        pressed - true if the element is pressed, false otherwise.