Class AbstractButton2

All Implemented Interfaces:
GUIElement, KeyPressedHandler, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
GUIButton, GUISelectableButton

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

    • AbstractButton2

      protected AbstractButton2(@NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, @NotNull @NotNull BufferedImage imageUp, @NotNull @NotNull BufferedImage imageDown, @Nullable @Nullable String text, @Nullable @Nullable Font font, @Nullable @Nullable Color color, int textX, int textY, 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
      text - the overlay text or null to display only the image
      font - the font for the overlay text or null to display only the image
      color - the color of the overlay text or null to display only the image
      textX - the x coordinate of the overlay text
      textY - the y coordinate of the overlay 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

    • paintComponent

      public void paintComponent(@NotNull @NotNull Graphics g)
      Overrides:
      paintComponent in class JComponent
    • isSelected

      protected abstract boolean isSelected()
      Returns which image should be shown.
      Returns:
      false=show "up" image, true=show "down" image
    • getMinimumSizeInt

      @NotNull protected @NotNull Dimension getMinimumSizeInt()
      Description copied from class: AbstractButton
      Returns the minimal size needed to display this component.
      Specified by:
      getMinimumSizeInt in class AbstractButton
      Returns:
      the minimal size
    • getMaximumSize

      @NotNull public @NotNull Dimension getMaximumSize()
      Overrides:
      getMaximumSize in class JComponent
    • getTooltip

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