java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
public class JComboBox extends JComponent
Constructor Summary |
---|
JComboBox()
Creates a JComboBox with a default data model. |
JComboBox(Object[] items)
Creates a JComboBox that contains the elements
in the specified array. |
Method Summary | |
---|---|
void |
addActionListener(ActionListener l)
Adds an ActionListener . |
void |
addItem(Object anObject)
Adds an item to the item list. |
Object |
getItemAt(int index)
Returns the list item at the specified index. |
int |
getItemCount()
Returns the number of items in the list. |
int |
getMaximumRowCount()
Returns the maximum number of items the combo box can display without a scrollbar |
int |
getSelectedIndex()
Returns the first item in the list that matches the given item. |
Object |
getSelectedItem()
Returns the current selected item. |
Object[] |
getSelectedObjects()
Returns an array containing the selected item. |
void |
insertItemAt(Object anObject,
int index)
Inserts an item into the item list at a given index. |
boolean |
isEditable()
Returns true if the JComboBox is editable. |
void |
removeAllItems()
Removes all items from the item list. |
void |
removeItem(Object anObject)
Removes an item from the item list. |
void |
removeItemAt(int anIndex)
Removes the item at anIndex
This method works only if the JComboBox uses a
mutable data model. |
void |
setEditable(boolean aFlag)
Determines whether the JComboBox field is editable. |
void |
setEnabled(boolean b)
Enables the combo box so that items can be selected. |
void |
setMaximumRowCount(int count)
Sets the maximum number of rows the JComboBox displays. |
void |
setSelectedIndex(int anIndex)
Selects the item at index anIndex . |
void |
setSelectedItem(Object anObject)
Sets the selected item in the combo box display area to the object in the argument. |