com.droplets.api
Class CheckboxMenuItemGroup

java.lang.Object
  |
  +--com.droplets.api.CheckboxMenuItemGroup
All Implemented Interfaces:
ItemSelectable

public class CheckboxMenuItemGroup
extends java.lang.Object
implements ItemSelectable

Enforces mutual exclusion among a group of CheckboxMenuItems . To use this class, add CheckboxMenuItems to the group using the add(CheckboxMenuItem) method. Note that you must also add CheckboxMenuItems to a menu separately.

ItemListeners can register with CheckboxMenuItemGroups using addItemListener to receive events when a selection in the group has changed.


Constructor Summary
CheckboxMenuItemGroup()
          Constructs a new CheckboxMenuItemGroup.
 
Method Summary
 void add(CheckboxMenuItem item)
          Adds a checkbox menu item to this group.
 void addItemListener(ItemListener l)
          Adds a listener to receive events from the CheckboxMenuItems in this group when their state changes.
 java.lang.Object[] getSelectedObjects()
           For ItemSelectable objects in general, returns the list of objects that are currently selected.
 void removeItemListener(ItemListener l)
          Removes an item listener from this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckboxMenuItemGroup

public CheckboxMenuItemGroup()
Constructs a new CheckboxMenuItemGroup.
Method Detail

add

public void add(CheckboxMenuItem item)
Adds a checkbox menu item to this group.
Parameters:
item - the item to add.

addItemListener

public void addItemListener(ItemListener l)
Adds a listener to receive events from the CheckboxMenuItems in this group when their state changes.

In the ItemEvent passed to ItemListener.itemStateChanged(com.droplets.api.event.ItemEvent) method, the getItem method returns the CheckboxMenuItem that is being selected or deselected.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
l - the listener to add

getSelectedObjects

public java.lang.Object[] getSelectedObjects()

For ItemSelectable objects in general, returns the list of objects that are currently selected. For CheckboxMenuItemGroups, this method returns the currently selected CheckboxMenuItem, or null if none are selected.

The selected item is the only element of the array, to conform to the ItemSelectable interface.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
java.lang.Object[]

removeItemListener

public void removeItemListener(ItemListener l)
Removes an item listener from this object. The listener is no longer be notified when an item in this group has changed state.
Specified by:
removeItemListener in interface ItemSelectable
Parameters:
l - the listener to remove


Copyright © Droplets, 2001. All Rights Reserved.