uk.ac.starlink.util.gui
Class ValueButtonGroup

java.lang.Object
  extended by javax.swing.ButtonGroup
      extended by uk.ac.starlink.util.gui.ValueButtonGroup
All Implemented Interfaces:
Serializable

public class ValueButtonGroup
extends ButtonGroup

Extends ButtonGroup by associating a value with each button.

Since:
11 Jan 2005
Author:
Mark Taylor
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.ButtonGroup
buttons
 
Constructor Summary
ValueButtonGroup()
          Constructor.
 
Method Summary
 void add(AbstractButton button, Object value)
          Adds a button and associates a value with it.
 void addChangeListener(ChangeListener listener)
          Adds a listener which will be notified whenever this group's selected value changes.
 Object getValue()
          Returns the currently selected value, that is the value associated with the currently selected button.
 void remove(AbstractButton button)
           
 void removeChangeListener(ChangeListener listener)
          Removes a listener previously added by addChangeListener.
 void setValue(Object value)
          Sets the currently selected value.
 
Methods inherited from class javax.swing.ButtonGroup
add, getButtonCount, getElements, getSelection, isSelected, setSelected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueButtonGroup

public ValueButtonGroup()
Constructor.

Method Detail

add

public void add(AbstractButton button,
                Object value)
Adds a button and associates a value with it. When button is selected, getValue() will return value. You can use null for a value, but don't have two buttons with associated values which are equal.

Parameters:
button - button
value - associated value

remove

public void remove(AbstractButton button)
Overrides:
remove in class ButtonGroup

getValue

public Object getValue()
Returns the currently selected value, that is the value associated with the currently selected button.

Returns:
selected value

setValue

public void setValue(Object value)
Sets the currently selected value. The associated button will be selected (and others deselected). value must be one of the values associated with a button in this group.

Parameters:
value - new value

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener which will be notified whenever this group's selected value changes.

Parameters:
listener - listener to add

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes a listener previously added by addChangeListener.

Parameters:
listener - listener to remove


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.