public class MenuSelector<T>
extends java.lang.Object
Constructor | Description |
---|---|
MenuSelector(java.lang.String name,
T[] options) |
Constructs a menu selector with an implicit default,
the first element of the supplied options array.
|
MenuSelector(java.lang.String name,
T[] options,
T dflt) |
Constructs a menu selector with an explicit default.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addActionListener(java.awt.event.ActionListener l) |
Adds a listener that will be notified whenever the selection changes.
|
javax.swing.JMenuItem |
getMenuItem() |
Returns the menu item that presents this selector.
|
T |
getSelectedItem() |
Returns the currently selected option.
|
void |
removeActionListener(java.awt.event.ActionListener l) |
Removes a previously-added listener.
|
void |
setSelectedItem(T option) |
Sets the currently selected option.
|
public MenuSelector(java.lang.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 MenuSelector(java.lang.String name, T[] options)
name
- menu nameoptions
- list of options that can be selectedpublic javax.swing.JMenuItem getMenuItem()
public T getSelectedItem()
public void setSelectedItem(T option)
option
- option to selectjava.lang.IllegalArgumentException
- if option
is not
one of the optionspublic void addActionListener(java.awt.event.ActionListener l)
l
- listener to addpublic void removeActionListener(java.awt.event.ActionListener l)
l
- listener to removeCopyright ? 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.