Class MenuSelector<T>
java.lang.Object
uk.ac.starlink.topcat.MenuSelector<T>
Provides a menu item with a submenu that can select one of a given
set of options. At present, the list of options is fixed.
- Since:
- 19 Sep 2017
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionMenuSelector(String name, T[] options) Constructs a menu selector with an implicit default, the first element of the supplied options array.MenuSelector(String name, T[] options, T dflt) Constructs a menu selector with an explicit default. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener that will be notified whenever the selection changes.Returns the menu item that presents this selector.Returns the currently selected option.voidRemoves a previously-added listener.voidsetSelectedItem(T option) Sets the currently selected option.
-
Constructor Details
-
MenuSelector
-
MenuSelector
-
-
Method Details
-
getMenuItem
Returns the menu item that presents this selector. It has a submenu hanging off it that provides the actual selection options (currently JRadioButtonMenuItems).- Returns:
- menu item
-
getSelectedItem
-
setSelectedItem
Sets the currently selected option.- Parameters:
option- option to select- Throws:
IllegalArgumentException- ifoptionis not one of the options
-
addActionListener
Adds a listener that will be notified whenever the selection changes.- Parameters:
l- listener to add
-
removeActionListener
Removes a previously-added listener.- Parameters:
l- listener to remove
-