fdda.dialog.swing.utils
Class ToggleButtonGroup

java.lang.Object
  |
  +--fdda.dialog.swing.utils.ToggleButtonGroup

public class ToggleButtonGroup
extends Object

Groups several ToggleButtons together so that only one of them is active at each point of time. There may be a 'default' button to revert to. In this case, reverting may also be blocked by selecting the current button 'sticky'.

Author:
Jörg Rüdenauer

Constructor Summary
ToggleButtonGroup()
          Constructor.
 
Method Summary
 void addButton(AbstractButton button)
          Adds a button to the group.
 boolean isSticky()
          Returns whether the current selection is 'sticky'.
 void removeButton(AbstractButton button)
          Removes a button from the group.
 boolean revertToDefaultButton()
          If a default button is specified and the current selection isn't sticky, selects the default button.
 void selectButton(AbstractButton button)
          Selects a button.
 void selectButton(AbstractButton button, boolean sticky)
          Selects a button.
 void selectButtonSticky(AbstractButton button)
          Selects a button.
 void setDefaultButton(AbstractButton button)
          Sets the default button.
 boolean unselectCurrentButton(AbstractButton button)
          Same as revertToDefaultButton, except that the sticky bit is ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToggleButtonGroup

public ToggleButtonGroup()
Constructor.

Method Detail

addButton

public void addButton(AbstractButton button)
Adds a button to the group. No check for doubles.

Parameters:
button - the button

removeButton

public void removeButton(AbstractButton button)
Removes a button from the group. No effect if button isn't in the group. If the button was the default button, no default button remains.

Parameters:
button - the button

setDefaultButton

public void setDefaultButton(AbstractButton button)
Sets the default button. If set to null, no default button is set.

Parameters:
button - the button or null

selectButton

public void selectButton(AbstractButton button)
Selects a button. Selection is not sticky. All other buttons are deselected.

Parameters:
button - the button
Throws:
IllegalArgumentException - if button isn't in the group

selectButtonSticky

public void selectButtonSticky(AbstractButton button)
Selects a button. Selection is sticky. All other buttons are deselected.

Parameters:
button - the button
Throws:
IllegalArgumentException - if button isn't in the group

selectButton

public void selectButton(AbstractButton button,
                         boolean sticky)
Selects a button. All other buttons are deselected

Parameters:
button - the button
sticky - whether the selection shall be sticky
Throws:
IllegalArgumentException - if button isn't in the group

revertToDefaultButton

public boolean revertToDefaultButton()
If a default button is specified and the current selection isn't sticky, selects the default button. Otherwise, does nothing.

Returns:
whether the default button was selected

unselectCurrentButton

public boolean unselectCurrentButton(AbstractButton button)
Same as revertToDefaultButton, except that the sticky bit is ignored.

Parameters:
button - the button
Returns:
whether the default button was selected

isSticky

public boolean isSticky()
Returns whether the current selection is 'sticky'.

Returns:
true, iff sticky


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.