Class GUISelectableButton

All Implemented Interfaces:
GUISelectable, GUIElement, KeyPressedHandler, ImageObserver, MenuContainer, Serializable

public class GUISelectableButton extends AbstractButton2 implements GUISelectable
A GUIElement that implements a button. The button shows an image and optionally overlays a text string.
See Also:
  • Constructor Details

    • GUISelectableButton

      public GUISelectableButton(@NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, @NotNull @NotNull BufferedImage imageUp, @NotNull @NotNull BufferedImage imageDown, @NotNull @NotNull String tooltipText, boolean autoRepeat, @NotNull @NotNull CommandList commandList, @NotNull @NotNull GuiFactory guiFactory, @NotNull @NotNull NewCharModel newCharModel)
      Creates a new instance. Both imageUp and imageDown must have the same size. The x/y coordinates specify the baseline of the first character of the overlay text.
      Parameters:
      tooltipManager - the tooltip manager to update
      elementListener - the element listener to notify
      name - the name of this element
      imageUp - the image in unselected state
      imageDown - the image in selected state
      tooltipText - the tooltip text
      autoRepeat - whether the button should autorepeat while being pressed
      commandList - the commands to execute when the button is elected
      guiFactory - the global GUI factory instance
      newCharModel - the global new char model instance
  • Method Details

    • isSelected

      protected boolean isSelected()
      Description copied from class: AbstractButton2
      Returns which image should be shown.
      Specified by:
      isSelected in class AbstractButton2
      Returns:
      false=show "up" image, true=show "down" image
    • select

      public void select(boolean selected)
      Description copied from interface: GUISelectable
      Selects or deselects the element.
      Specified by:
      select in interface GUISelectable
      Parameters:
      selected - whether the element should be selected
    • activeChanged

      protected void activeChanged()
      Description copied from class: ActivatableGUIElement
      Will be called whenever the active state has changed.
      Specified by:
      activeChanged in class ActivatableGUIElement
    • getTooltip

      @Nullable public @Nullable TooltipText getTooltip()
      Description copied from class: AbstractGUIElement
      Returns the current tooltip text.
      Overrides:
      getTooltip in class AbstractButton2
      Returns:
      the tooltip text or null to not show a tooltip
    • notifyOpen

      public void notifyOpen()
      Description copied from interface: GUIElement
      Called each time the enclosing dialog is opened (or raised).
      Specified by:
      notifyOpen in interface GUIElement