Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## charvax.swing
Class JComboBox

    java.lang.Object
      charva.awt.Component
          charvax.swing.JComponent
              charvax.swing.JComboBox

All Implemented Interfaces:
  EventListener, ItemSelectable, ListSelectionListener

public class JComboBox
extends JComponent
implements ListSelectionListener, ItemSelectable

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

### _actionListeners

    protected java.util.Vector _actionListeners

  A list of ActionListeners registered for this component.

### _itemListeners

    protected java.util.Vector _itemListeners

  A list of ItemListeners registered for this component.

Constructor Detail

### JComboBox

    public JComboBox()

  Creates an empty JComboBox.

### JComboBox

    public JComboBox(ComboBoxModel model)

  Creates a JComboBox with the given model.

### JComboBox

    public JComboBox(java.lang.Object[] items_)

  Creates a JComboBox that contains the elements in the specified array.

Parameters:
  `items_` - the array of items to display in the combobox

### JComboBox

    public JComboBox(java.util.Vector items_)

  Creates a JComboBox that contains the elements in the specified Vector.

Parameters:
  `items_` - the vector of items to display in the combobox

Method Detail

### setModel

    public void setModel(ComboBoxModel model_)

  Sets the data model that the JComboBox uses to obtain the list of items.

### addItem

    public void addItem(java.lang.Object item_)

  Add the specified item into the list of items.

  Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).

### insertItemAt

    public void insertItemAt(java.lang.Object item_,
                             int index_)

  Insert the specified item at the specified index.

  Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).

### removeItemAt

    public void removeItemAt(int index_)

  Remove the item at the specified index.

  Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).

### removeItem

    public void removeItem(java.lang.Object item_)

  Removes the specified item from the combobox's list. If the item was not in the list, the list is not changed.

  Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).

### removeAllItems

    public void removeAllItems()

  Removes all items.

  Note that this method works only if the data model is a MutableComboBoxModel (by default, it is).

### getSelectedItem

    public java.lang.Object getSelectedItem()

  Returns the selected item.

### setSelectedItem

    public void setSelectedItem(java.lang.Object obj_)

  Sets the selected item in the JComboBox by specifying the object in the list.

### setSelectedIndex

    public void setSelectedIndex(int index_)

  Sets the selected item in the JComboBox by specifying the index in the list.

### setMaximumRowCount

    public void setMaximumRowCount(int rows_)

  Sets the maximum number of rows that the JComboBox displays.

### getWidth

    public int getWidth()

  Returns width (including the diamond symbol).

  Specified by:
    `getWidth` in class `Component`

### getHeight

    public int getHeight()

  Specified by:
    `getHeight` in class `Component`

### getSize

    public Dimension getSize()

  Specified by:
    `getSize` in class `Component`

### minimumSize

    public Dimension minimumSize()

  Specified by:
    `minimumSize` in class `Component`

### draw

    public void draw()

  Draw the selected item, surrounded by a box.

  Overrides:
    `draw` in class `JComponent`

### addItemListener

    public void addItemListener(ItemListener il_)

  Register an ItemListener object for this component.

  Specified by:
    `addItemListener` in interface `ItemSelectable`

### removeItemListener

    public void removeItemListener(ItemListener listener_)

  Specified by:
    `removeItemListener` in interface `ItemSelectable`

### fireItemStateChanged

    protected void fireItemStateChanged(ItemEvent ie_)

  Invoke all the ItemListener callbacks that may have been registered for this component.

### processEvent

    public void processEvent(AWTEvent evt_)

  Overrides method in superclass.

  Overrides:
    `processEvent` in class `Component`

### addActionListener

    public void addActionListener(ActionListener al_)

  Register an ActionListener object for this component.

### fireActionEvent

    protected void fireActionEvent(ActionEvent ae_)

  Invoke all the ActionListener callbacks that may have been registered for this component.

### processKeyEvent

    public void processKeyEvent(KeyEvent ke_)

  Process KeyEvents that have been generated by this JComboBox component.

  Overrides:
    `processKeyEvent` in class `Component`

### processMouseEvent

    public void processMouseEvent(MouseEvent e_)

  Process a MouseEvent that was generated by clicking the mouse on this JComboBox.

  Overrides:
    `processMouseEvent` in class `Component`

### setEditable

    public void setEditable(boolean editable)

  Make the combobox editable.

### valueChanged

    public void valueChanged(ListSelectionEvent e_)

  Implements the ListSelectionListener interface.

  Specified by:
    `valueChanged` in interface `ListSelectionListener`

### requestFocus

    public void requestFocus()

  Description copied from class: `Component`
  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.

  Overrides:
    `requestFocus` in class `Component`

### toString

    public java.lang.String toString()

  Returns a String representation of this component.

### debug

    public void debug(int level_)

  Output a description of this component to stderr.

  Specified by:
    `debug` in class `Component`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD