|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object charva.awt.Component charvax.swing.JComponent charvax.swing.JComboBox
The JComboBox component allows the user to select an item from a pop-up list of choices.
When the combobox is in a non-popped-up state, it looks like a JButton with a "diamond" character on the right. To make the popup menu appear, the user positions the cursor over the combobox and presses ENTER.
When the user selects an item in the popup menu (by positioning the cursor on it and pressing ENTER), the pop-up menu disappears and only the selected item is shown. At the same time the JComboBox posts an ActionEvent onto the system event queue. The "action command" encapsulated in the ActionEvent is the list item that was selected.
Note that this class provides an "Uneditable" JComboBox only.
Field Summary | |
protected java.util.Vector |
_actionListeners
A list of ActionListeners registered for this component. |
protected java.util.Vector |
_itemListeners
A list of ItemListeners registered for this component. |
Fields inherited from class charvax.swing.JComponent |
_border |
Fields inherited from class charva.awt.Component |
_alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
JComboBox()
Creates an empty JComboBox. |
|
JComboBox(ComboBoxModel model)
Creates a JComboBox with the given model. |
|
JComboBox(java.lang.Object[] items_)
Creates a JComboBox that contains the elements in the specified array. |
|
JComboBox(java.util.Vector items_)
Creates a JComboBox that contains the elements in the specified Vector. |
Method Summary | |
void |
addActionListener(ActionListener al_)
Register an ActionListener object for this component. |
void |
addItem(java.lang.Object item_)
Add the specified item into the list of items. |
void |
addItemListener(ItemListener il_)
Register an ItemListener object for this component. |
void |
debug(int level_)
Output a description of this component to stderr. |
void |
draw()
Draw the selected item, surrounded by a box. |
protected void |
fireActionEvent(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this component. |
protected void |
fireItemStateChanged(ItemEvent ie_)
Invoke all the ItemListener callbacks that may have been registered for this component. |
int |
getHeight()
|
java.lang.Object |
getSelectedItem()
Returns the selected item. |
Dimension |
getSize()
|
int |
getWidth()
Returns width (including the diamond symbol). |
void |
insertItemAt(java.lang.Object item_,
int index_)
Insert the specified item at the specified index. |
Dimension |
minimumSize()
|
void |
processEvent(AWTEvent evt_)
Overrides method in superclass. |
void |
processKeyEvent(KeyEvent ke_)
Process KeyEvents that have been generated by this JComboBox component. |
void |
processMouseEvent(MouseEvent e_)
Process a MouseEvent that was generated by clicking the mouse on this JComboBox. |
void |
removeAllItems()
Removes all items. |
void |
removeItem(java.lang.Object item_)
Removes the specified item from the combobox's list. |
void |
removeItemAt(int index_)
Remove the item at the specified index. |
void |
removeItemListener(ItemListener listener_)
|
void |
requestFocus()
This method should be invoked by all subclasses of Component which override this method; because this method generates the FOCUS_GAINED event when the component gains the keyboard focus. |
void |
setEditable(boolean editable)
Make the combobox editable. |
void |
setMaximumRowCount(int rows_)
Sets the maximum number of rows that the JComboBox displays. |
void |
setModel(ComboBoxModel model_)
Sets the data model that the JComboBox uses to obtain the list of items. |
void |
setSelectedIndex(int index_)
Sets the selected item in the JComboBox by specifying the index in the list. |
void |
setSelectedItem(java.lang.Object obj_)
Sets the selected item in the JComboBox by specifying the object in the list. |
java.lang.String |
toString()
Returns a String representation of this component. |
void |
valueChanged(ListSelectionEvent e_)
Implements the ListSelectionListener interface. |
Methods inherited from class charvax.swing.JComponent |
getBorder, getInsets, setBorder |
Methods inherited from class charva.awt.Component |
addFocusListener, addKeyListener, contains, contains, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getLocation, getLocationOnScreen, getName, getParent, hasFocus, hide, invalidate, isDisplayed, isEnabled, isFocusTraversable, isTotallyObscured, isValid, isVisible, processFocusEvent, repaint, requestSync, setBackground, setBounds, setBounds, setBounds, setEnabled, setForeground, setLocation, setLocation, setName, setParent, setVisible, show, validate, validateCursesColor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Vector _actionListeners
protected java.util.Vector _itemListeners
Constructor Detail |
public JComboBox()
public JComboBox(ComboBoxModel model)
public JComboBox(java.lang.Object[] items_)
items_
- the array of items to display in the comboboxpublic JComboBox(java.util.Vector items_)
items_
- the vector of items to display in the comboboxMethod Detail |
public void setModel(ComboBoxModel model_)
public void addItem(java.lang.Object item_)
Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).
public void insertItemAt(java.lang.Object item_, int index_)
Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).
public void removeItemAt(int index_)
Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).
public void removeItem(java.lang.Object item_)
Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).
public void removeAllItems()
public java.lang.Object getSelectedItem()
public void setSelectedItem(java.lang.Object obj_)
public void setSelectedIndex(int index_)
public void setMaximumRowCount(int rows_)
public int getWidth()
getWidth
in class Component
public int getHeight()
getHeight
in class Component
public Dimension getSize()
getSize
in class Component
public Dimension minimumSize()
minimumSize
in class Component
public void draw()
draw
in class JComponent
public void addItemListener(ItemListener il_)
addItemListener
in interface ItemSelectable
public void removeItemListener(ItemListener listener_)
removeItemListener
in interface ItemSelectable
protected void fireItemStateChanged(ItemEvent ie_)
public void processEvent(AWTEvent evt_)
processEvent
in class Component
public void addActionListener(ActionListener al_)
protected void fireActionEvent(ActionEvent ae_)
public void processKeyEvent(KeyEvent ke_)
processKeyEvent
in class Component
public void processMouseEvent(MouseEvent e_)
processMouseEvent
in class Component
public void setEditable(boolean editable)
public void valueChanged(ListSelectionEvent e_)
valueChanged
in interface ListSelectionListener
public void requestFocus()
Component
requestFocus
in class Component
public java.lang.String toString()
public void debug(int level_)
debug
in class Component
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |