|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vmm.actions.ActionRadioGroup
public class ActionRadioGroup
An ActionRadioGroup represents a group of mutually exclusive options. Only one of the
options can be selected at a given time; this rule is enforced by the group. Methods are
provided for getting sets of JRadioButtons or JRadioButtonMenuItems to represent
the group of options; the user can manipulate one of the buttons or menu items to
change the currently selected option. When the selected option changes because of
a user action, the optionSelected(int)
method is called; override this method
in a subclass to perform some action when the user changes the selection.
Constructor Summary | |
---|---|
ActionRadioGroup()
Create an initially empty option group. |
|
ActionRadioGroup(java.lang.String[] actionNames)
Create a group of options in which initially no option is selected. |
|
ActionRadioGroup(java.lang.String[] actionNames,
int selectedIndex)
Create a group of options in which a specifed option is initially selected. |
Method Summary | |
---|---|
int |
addItem(java.lang.String itemName)
Adds an option to the group. |
javax.swing.JRadioButtonMenuItem[] |
createRadioButtonMenuItems()
Return a list of radio button menu items that are synchronized with the selection state of the options in this group. |
javax.swing.JRadioButton[] |
createRadioButtons()
Return a list of radio buttons that are synchronized with the selection state of the options in this group. |
int |
getItemCount()
Returns the number of items in the group. |
javax.swing.JMenuItem[] |
getMenuItems()
Returns the same array that would be returned by createRadioButtonMenuItems() . |
int |
getSelectedIndex()
Return the index of the currently selected option, or -1 if no option is currently selected. |
boolean |
isEnabled()
Get the current enabled status of the this action group. |
void |
optionSelected(int selectedIndex)
This method is called when one of the options is selected because of a user action on one of the radio buttons or menu items returned by createRadioButtonMenuItems() or createRadioButtons() . |
void |
setEnabled(boolean enabled)
Set the enabled status of the Actions (and hence the buttons and menu items) associated with this group. |
void |
setSelectedIndex(int index)
Set the currently selected option. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActionRadioGroup()
public ActionRadioGroup(java.lang.String[] actionNames)
actionNames
- Names for the options, which become names of menu items or names or radio buttons.
Null values are OK and are meant to represent separators in a menu. If actionNames is null, the
list of actions is initially empty.public ActionRadioGroup(java.lang.String[] actionNames, int selectedIndex)
actionNames
- Names for the options, which become names of menu items or names or radio buttons.
Null values are OK and are meant to represent separators in a menu. If actionNames is null, the
list of actions is initially empty.selectedIndex
- The index in actionNames of the initially selected index, or -1 to indicate
that no item is initially selected. If this value is outside the range of indicies for actionNames,
or if actionNames[selectedIndex] is null, then the value is silently changed to -1.Method Detail |
---|
public void optionSelected(int selectedIndex)
createRadioButtonMenuItems()
or createRadioButtons()
.
It is not called when the selected index is changed programmatically by setSelectedIndex(int)
.
In this class, this method does nothing. Subclasses can override this method to perform some action when the
user changes the selection. Note that this method will be called even when the user selects the option
that is already selected.
selectedIndex
- The index of the item that was selected, or -1 to indicate that no option is selected.public javax.swing.JRadioButtonMenuItem[] createRadioButtonMenuItems()
public javax.swing.JRadioButton[] createRadioButtons()
public int addItem(java.lang.String itemName)
itemName
- The name of the option, or null if this item is meant to represent a separator in a menu.
public int getSelectedIndex()
public void setSelectedIndex(int index)
index
- the option to be selected, or -1 to indicate that no option is selected. Any
value outside the range of legal option numbers is treated as -1. Also, an index for which
the option is a null value is treated as -1.public void setEnabled(boolean enabled)
public boolean isEnabled()
setEnabled(boolean)
public javax.swing.JMenuItem[] getMenuItems()
createRadioButtonMenuItems()
.
getMenuItems
in interface ActionItem
public int getItemCount()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |