Class RadioGroupWidgetHandler
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.components.RadioGroupWidgetHandler
-
- All Implemented Interfaces:
WidgetHandler
public class RadioGroupWidgetHandler extends Object implements WidgetHandler
A specialized
WidgetHandler
implementation for radio groups.Radio groups in UI libraries are typically somewhat special. They are not graphical components on their own, but merely refer to the actual radio button components. However, in the JGUIraffe library radio groups are more or less treated like regular components, and their properties can be accessed through the
WidgetHandler
interface.Because of this a special implementation is needed for radio buttons. This implementations acts like a typical composite. Set operations are delegated to all components in the group. For get operations there are some limitations: Unless noted otherwise for a specific operation, the group widget handler expects that all radio buttons in the group share the same properties (e.g. colors or visible state). Therefore it simply returns the corresponding property of the first button in the group.
Implementation notes: This implementation is fully functional and can be used independent on the underlying UI library. This is possible because radio button controls are accessed only via the
WidgetHandler
interface. This class is not thread-safe. It should be accessed from the event dispatch thread only.- Since:
- 1.4
-
-
Constructor Summary
Constructors Constructor Description RadioGroupWidgetHandler(Object group, Collection<? extends WidgetHandler> radios, String toolTipSeparator)
Creates a new instance ofRadioGroupWidgetHandler
that handles the given collection of radio buttons.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Color
getBackgroundColor()
Returns the background color of the underlying widget.Object
getFont()
Returns the font of this widget.Color
getForegroundColor()
Returns the foreground color of the underlying widget.List<WidgetHandler>
getRadioButtons()
Returns a (unmodifiable) list with the widget handlers of the radio buttons managed by this object.String
getTipSeparator()
Returns the separator between two combined tool tips.String
getToolTip()
Returns the tool tip text of the underlying widget.Object
getWidget()
Returns a reference to the underlying widget.boolean
isVisible()
Returns a flag whether the wrapped widget is currently visible.void
setBackgroundColor(Color c)
Sets the background color of the underlying widget.void
setFont(Object font)
Sets the font of this widget.void
setForegroundColor(Color c)
Sets the foreground color of the underlying widget.void
setToolTip(String tip)
Sets the tool tip text of the underlying widget.void
setVisible(boolean f)
Sets the visible flag of the wrapped widget.
-
-
-
Constructor Detail
-
RadioGroupWidgetHandler
public RadioGroupWidgetHandler(Object group, Collection<? extends WidgetHandler> radios, String toolTipSeparator)
Creates a new instance ofRadioGroupWidgetHandler
that handles the given collection of radio buttons.- Parameters:
group
- the object representing the button groupradios
- the collection with radio buttons to be managedtoolTipSeparator
- the separator for tool tips
-
-
Method Detail
-
getRadioButtons
public List<WidgetHandler> getRadioButtons()
Returns a (unmodifiable) list with the widget handlers of the radio buttons managed by this object.- Returns:
- the handlers of the managed radio buttons
-
getTipSeparator
public String getTipSeparator()
Returns the separator between two combined tool tips.- Returns:
- the tool tip separator
-
getWidget
public Object getWidget()
Description copied from interface:WidgetHandler
Returns a reference to the underlying widget. This is the platform-specific GUI control. For instance, if Swing was used as GUI platform, aComponent
object would be returned.- Specified by:
getWidget
in interfaceWidgetHandler
- Returns:
- the underlying GUI control
-
isVisible
public boolean isVisible()
Returns a flag whether the wrapped widget is currently visible. This implementation expects that all buttons in the group have the same visible state. So only the first button is checked.- Specified by:
isVisible
in interfaceWidgetHandler
- Returns:
- the visible flag of the wrapped widget
-
setVisible
public void setVisible(boolean f)
Sets the visible flag of the wrapped widget. Using this method a widget can be hidden and made visible again. This implementation changes the visibility state of all radio buttons in this group.- Specified by:
setVisible
in interfaceWidgetHandler
- Parameters:
f
- the visible flag of the wrapped widget
-
getBackgroundColor
public Color getBackgroundColor()
Returns the background color of the underlying widget. This implementation assumes that all buttons in the group have the same background color. So the property of the first button is returned.- Specified by:
getBackgroundColor
in interfaceWidgetHandler
- Returns:
- the background color of this widget
-
setBackgroundColor
public void setBackgroundColor(Color c)
Sets the background color of the underlying widget. This implementation sets the new background color for all radio buttons in this group.- Specified by:
setBackgroundColor
in interfaceWidgetHandler
- Parameters:
c
- the new background color (as a platform-independentColor
object); if the passed in color object is null, this operation has no effect
-
getForegroundColor
public Color getForegroundColor()
Returns the foreground color of the underlying widget. This implementation assumes that all buttons in the group have the same foreground color. So the property of the first button is returned.- Specified by:
getForegroundColor
in interfaceWidgetHandler
- Returns:
- the foreground color of this widget
-
setForegroundColor
public void setForegroundColor(Color c)
Sets the foreground color of the underlying widget. This implementation sets the new foreground color for all radio buttons in this group.- Specified by:
setForegroundColor
in interfaceWidgetHandler
- Parameters:
c
- the new background color (as a platform-independentColor
object); if the passed in color object is null, this operation has no effect
-
getToolTip
public String getToolTip()
Returns the tool tip text of the underlying widget. This can be null if no tool tip was set. Note: It is possible that an implementation returns a different tool tip text than the one passed toWidgetHandler.setToolTip(String)
. This is due to the fact that certain control characters like line feeds may have to be converted by a concrete implementation. To avoid confusion related to changed tool tips client code should only interact with theToolTipManager
to manipulate tool tips. This implementation returns the tool tip of the whole radio group. This tool tip is independent of the tips of single radio buttons. So this implementation just returns the string that was set usingsetToolTip(String)
.- Specified by:
getToolTip
in interfaceWidgetHandler
- Returns:
- the tool tip of this widget
-
setToolTip
public void setToolTip(String tip)
Sets the tool tip text of the underlying widget. Note: Client code should not call this method directly. Rather, theToolTipManager
should be used for setting tool tips for widgets. This implementation sets the overall tool tip, and it changes the tool tips of the radio buttons that belong to this group. The tool tips of the radio buttons are generated by their original tool tip, a separator, plus the group's tool tip.- Specified by:
setToolTip
in interfaceWidgetHandler
- Parameters:
tip
- the new tool tip text
-
getFont
public Object getFont()
Returns the font of this widget. This is a platform-specific object. This implementation assumes that all buttons in the group have the same font. So the property of the first button is returned.- Specified by:
getFont
in interfaceWidgetHandler
- Returns:
- the font of this widget
-
setFont
public void setFont(Object font)
Sets the font of this widget. The font is a platform-specific object. It can be created in builder scripts using the<f:font>
tag or directly using thecreateFont()
method ofComponentManager
. Concrete implementations may throw a runtime exception if the font object passed to this method is invalid. This implementation sets the new font for all radio buttons in this group.- Specified by:
setFont
in interfaceWidgetHandler
- Parameters:
font
- the font to be set
-
-