22 package com.realtime.crossfire.jxclient.gui.label;
27 import java.awt.Color;
29 import java.awt.Graphics;
30 import java.awt.Transparency;
31 import java.awt.image.BufferedImage;
32 import javax.swing.ImageIcon;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
93 super(tooltipManager, elementListener, name, Transparency.TRANSLUCENT);
97 backgroundImage = backgroundPicture == null ? null :
new ImageIcon(backgroundPicture);
105 public void setText(@NotNull
final String text) {
106 if (!this.text.equals(text)) {
149 super.paintComponent(g);
151 if (backgroundImage != null) {
152 g.drawImage(backgroundImage.getImage(), 0, 0, null);
153 }
else if (backgroundColor != null) {
154 g.setColor(backgroundColor);
155 g.fillRect(0, 0, getWidth(), getHeight());
Listener for GUIElement related events.
Abstract base class for all label classes.
void setText(@NotNull final String text)
The label text.
final TooltipManager tooltipManager
The TooltipManager to update.
final Color textColor
The text color.
final Font textFont
The font for rendering the label text.
void setChanged()
Records that the contents have changed and must be repainted.
abstract void textChanged()
Will be called whenever text has changed.
void paintComponent(@NotNull final Graphics g)
Color getTextColor()
Returns the text color.
final GUIElementListener elementListener
The GUIElementListener to notify.
AbstractLabel(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final String text, @NotNull final Font textFont, @NotNull final Color textColor, @Nullable final BufferedImage backgroundPicture, @Nullable final Color backgroundColor)
Creates a new instance.
final Color backgroundColor
If set, the opaque background color.
final String name
The name of this element.
Font getTextFont()
Returns the font.
void setBackgroundImage(@Nullable final ImageIcon backgroundImage)
Sets the background image.
String getText()
Returns the label text.
String text
The label text.
Abstract base class for GUI elements to be shown in Guis.
ImageIcon backgroundImage
The background image.
static final long serialVersionUID
The serial version UID.