public class MenuSelector<T> extends Object
Constructor and Description |
---|
MenuSelector(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.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Adds a listener that will be notified whenever the selection changes.
|
JMenuItem |
getMenuItem()
Returns the menu item that presents this selector.
|
T |
getSelectedItem()
Returns the currently selected option.
|
void |
removeActionListener(ActionListener l)
Removes a previously-added listener.
|
void |
setSelectedItem(T option)
Sets the currently selected option.
|
public MenuSelector(String name, T[] options, T dflt)
name
- menu nameoptions
- list of options that can be selecteddflt
- initial default value;
should be one of options
public JMenuItem getMenuItem()
public T getSelectedItem()
public void setSelectedItem(T option)
option
- option to selectIllegalArgumentException
- if option
is not
one of the optionspublic void addActionListener(ActionListener l)
l
- listener to addpublic void removeActionListener(ActionListener l)
l
- listener to removeCopyright © 2003-2025 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.