Class AbstractLabel

All Implemented Interfaces:
GUIElement, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
GUIHTMLLabel, GUILabel

public abstract class AbstractLabel extends AbstractGUIElement
Abstract base class for all label classes. It manages the label text, and renders the label's background.
See Also:
  • Constructor Details

    • AbstractLabel

      protected AbstractLabel(@NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, @NotNull @NotNull String text, @NotNull @NotNull Font textFont, @NotNull @NotNull Color textColor, @NotNull @NotNull Color textHighlightColor, @Nullable @Nullable BufferedImage backgroundPicture, @Nullable @Nullable Color backgroundColor, @NotNull @NotNull GuiFactory guiFactory)
      Creates a new instance.
      Parameters:
      tooltipManager - the tooltip manager to update
      elementListener - the element listener to notify
      name - the name of this element
      text - the text
      textFont - the text font
      textColor - the text color when not highlighted
      textHighlightColor - the text color when highlighted
      backgroundPicture - the optional background picture
      backgroundColor - the background color; ignored if background picture is set
      guiFactory - the global GUI factory instance
  • Method Details

    • setText

      public void setText(@NotNull @NotNull String text)
      Sets the label text.
      Parameters:
      text - the text
    • setTextHighlight

      public void setTextHighlight(boolean textHighlight)
      Sets whether the text should be highlighted.
      Parameters:
      textHighlight - whether the text is highlighted
    • textChanged

      protected void textChanged()
      Will be called whenever text or getTextColor() has changed.
    • getText

      @NotNull protected @NotNull String getText()
      Returns the label text.
      Returns:
      the label text
    • getTextFont

      @NotNull protected @NotNull Font getTextFont()
      Returns the font.
      Returns:
      the font
    • getTextColor

      @NotNull protected @NotNull Color getTextColor()
      Returns the text color.
      Returns:
      the text color
    • paintComponent

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