Class 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 Detail

      • RadioGroupWidgetHandler

        public RadioGroupWidgetHandler​(Object group,
                                       Collection<? extends WidgetHandler> radios,
                                       String toolTipSeparator)
        Creates a new instance of RadioGroupWidgetHandler that handles the given collection of radio buttons.
        Parameters:
        group - the object representing the button group
        radios - the collection with radio buttons to be managed
        toolTipSeparator - 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, a Component object would be returned.
        Specified by:
        getWidget in interface WidgetHandler
        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 interface WidgetHandler
        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 interface WidgetHandler
        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 interface WidgetHandler
        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 interface WidgetHandler
        Parameters:
        c - the new background color (as a platform-independent Color 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 interface WidgetHandler
        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 interface WidgetHandler
        Parameters:
        c - the new background color (as a platform-independent Color 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 to WidgetHandler.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 the ToolTipManager 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 using setToolTip(String).
        Specified by:
        getToolTip in interface WidgetHandler
        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, the ToolTipManager 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 interface WidgetHandler
        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 interface WidgetHandler
        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 the createFont() method of ComponentManager. 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 interface WidgetHandler
        Parameters:
        font - the font to be set