public class SelectField extends AbstractListComponent
SelectField component: a selection component which displays selection items in a drop-down field. Allows the
selection of only one item at a time. Does not support child components.
One item of the select field will always be displayed as being selected. If the model does not specify a selected item,
the first item will be selected. Note that the getSelectedItem() and getSelectedIndex() methods
of this object will reflect such selection, even when the model itself does not.
ACTION_LISTENERS_CHANGED_PROPERTY, DEFAULT_LIST_CELL_RENDERER, INPUT_ACTION, LIST_CELL_RENDERER_CHANGED_PROPERTY, LIST_DATA_CHANGED_PROPERTY, LIST_MODEL_CHANGED_PROPERTY, PROPERTY_ACTION_COMMAND, PROPERTY_BORDER, PROPERTY_DISABLED_BACKGROUND, PROPERTY_DISABLED_BORDER, PROPERTY_DISABLED_FONT, PROPERTY_DISABLED_FOREGROUND, PROPERTY_HEIGHT, PROPERTY_INSETS, PROPERTY_ROLLOVER_BACKGROUND, PROPERTY_ROLLOVER_ENABLED, PROPERTY_ROLLOVER_FONT, PROPERTY_ROLLOVER_FOREGROUND, PROPERTY_TOOL_TIP_TEXT, PROPERTY_WIDTH, SELECTION_CHANGED_PROPERTY, SELECTION_MODEL_CHANGED_PROPERTYCHILD_VISIBLE_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_NEXT_ID_CHANGED_PROPERTY, FOCUS_PREVIOUS_ID_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY| Constructor and Description |
|---|
SelectField()
Creates a new, empty
SelectField. |
SelectField(ListModel model)
Creates a new
SelectField with the provided model. |
SelectField(java.lang.Object[] items)
Creates a new
SelectField that will initially contain the
provided array of items. |
| Modifier and Type | Method and Description |
|---|---|
int |
getSelectedIndex()
Returns the index of the currently selected item.
|
java.lang.Object |
getSelectedItem()
Returns the currently selected item.
|
void |
setSelectedIndex(int index)
Sets the selected index.
|
void |
setSelectedItem(java.lang.Object item)
Sets the selected item.
|
addActionListener, getActionCommand, getBorder, getCellRenderer, getDisabledBackground, getDisabledBorder, getDisabledFont, getDisabledForeground, getHeight, getInsets, getModel, getRolloverBackground, getRolloverFont, getRolloverForeground, getSelectionModel, getToolTipText, getWidth, hasActionListeners, isRolloverEnabled, isValidChild, processInput, removeActionListener, setActionCommand, setBorder, setCellRenderer, setDisabledBackground, setDisabledBorder, setDisabledFont, setDisabledForeground, setHeight, setInsets, setModel, setRolloverBackground, setRolloverEnabled, setRolloverFont, setRolloverForeground, setSelectionModel, setToolTipText, setWidthadd, add, addPropertyChangeListener, addPropertyChangeListener, dispose, firePropertyChange, get, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusNextId, getFocusPreviousId, getFont, getForeground, getId, getIndex, getLayoutData, getLayoutDirection, getLocale, getLocalStyle, getParent, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, removePropertyChangeListener, set, setBackground, setComponents, setEnabled, setFocusNextId, setFocusPreviousId, setFocusTraversalParticipant, setFont, setForeground, setId, setIndex, setLayoutData, setLayoutDirection, setLocale, setRenderId, setStyle, setStyleName, setVisible, validate, verifyInput, visibleIndexOfpublic SelectField()
SelectField.public SelectField(ListModel model)
SelectField with the provided model.model - the model for the SelectFieldpublic SelectField(java.lang.Object[] items)
SelectField that will initially contain the
provided array of items.items - the items the SelectField will initially
containpublic int getSelectedIndex()
public java.lang.Object getSelectedItem()
public void setSelectedIndex(int index)
index - the new selected indexpublic void setSelectedItem(java.lang.Object item)
item - the new selected item