 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.misc;
33 import java.awt.Color;
34 import java.awt.Dimension;
36 import java.awt.Graphics;
37 import java.awt.Graphics2D;
38 import java.awt.Image;
39 import java.awt.event.MouseEvent;
40 import java.awt.geom.RectangularShape;
41 import java.awt.image.BufferedImage;
42 import org.jetbrains.annotations.NotNull;
43 import org.jetbrains.annotations.Nullable;
114 throw new IllegalArgumentException(
"'checked' width is "+
checkedImage.getWidth()+
" but 'unchecked' width is "+
uncheckedImage.getWidth());
134 super.paintComponent(g);
135 final Graphics2D g2 = (Graphics2D)g;
139 final RectangularShape rectangle =
font.getStringBounds(
text, g2.getFontRenderContext());
140 final int y = (int)Math.round(getHeight()-rectangle.getMaxY()-rectangle.getMinY())/2;
146 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
153 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
176 super.mouseClicked(e);
182 final int b = e.getButton();
184 case MouseEvent.BUTTON1:
188 case MouseEvent.BUTTON2:
191 case MouseEvent.BUTTON3:
final CheckBoxOption option
The option to display.
void removeOptionListener(@NotNull final OptionListener listener)
Removes a listener for state changes.
void toggleChecked()
Toggles the checked state.
static final long serialVersionUID
The serial version UID.
static Dimension getTextDimension(@NotNull final String text, @NotNull final FontMetrics fontMetrics)
Returns the extents of a string when rendered in a given Font on this component.
A GUIElement that can be set to active or inactive.
GUICheckBox(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final BufferedImage checkedImage, @NotNull final BufferedImage uncheckedImage, @NotNull final Font font, @NotNull final Color color, @NotNull final CheckBoxOption option, @NotNull final String text, @NotNull final GuiFactory guiFactory)
Creates a new instance.
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
final BufferedImage checkedImage
The image for the checked [x] state.
Dimension getMinimumSizeInt()
Returns the minimal size needed to display both icon and text.
void dispose()
Releases all allocated resources.
String getTooltipText()
Returns the tooltip text to explain this option.
void addOptionListener(@NotNull final OptionListener listener)
Adds a listener for state changes.
Utility class for Gui related functions.
void mouseClicked(@NotNull final MouseEvent e)
Will be called when the user has clicked (pressed+released) this element.
boolean isChecked()
Returns the current state.
final Image uncheckedImage
The image for the unchecked [ ] state.
final String text
The text.
void execute()
Executes the actions associated with this GUI element.
final GuiFactory guiFactory
The global GuiFactory instance.
TooltipText newTooltipText(@Nullable final String tooltipText)
Creates a TooltipText instance relative to this instance.
final GUIElementListener elementListener
The GUIElementListener to notify.
Dimension getMinimumSize()
void activeChanged()
Will be called whenever the active state has changed.
Information for displaying tooltips.
Factory for creating Gui instances.
final String name
The name of this element.
final Color color
The text color.
final Font font
The font to use.
Interface for listeners for attribute changes of Options.
final OptionListener optionListener
The OptionListener attached to option.
final TooltipManager tooltipManager
The TooltipManager to update.
The base class for all check box options.
void paintComponent(@NotNull final Graphics g)
TooltipText getTooltip()
Returns the current tooltip text.
Dimension getPreferredSize()
Listener for GUIElement related events.