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

## jcontrol.ui.vole
Class ComboBox

    java.lang.Object
      jcontrol.ui.vole.Component
          jcontrol.ui.vole.ComboBox

    public class ComboBox

extends Component

The class `ComboBox` implements a graphical combo box for the Vole GUI. The user can open the combo box giving a KEY_SELECT event and chose an entry using the KEY_SCROLL_UP and KEY_SCROLL_DOWN events. With another KEY_SELECT event, the choice is taken and the box is closed.

When the user changes the state, an `ActionEvent` of type `ITEM_SELECTED` is fired.

(c) Copyright 2003-2007 DOMOLOGIC GmbH

Field Summary

Fields inherited from class jcontrol.ui.vole.Component
`eventQueue, focusOwner, font, g, height, listener, parent, visible, width, x, y`

Constructor Summary
`ComboBox()` Creates a new and empty ComboBox.
`ComboBox(int x, int y)` Constructs a new empty `ComboBox` at the given x- and y-coordinates.
`ComboBox(String[] items, int x, int y)` Constructs a new `ComboBox` with a list of items at the given x- and y-coordinates.
`ComboBox(String[] items, int x, int y, int width)` Constructs a new `ComboBox` with a list of items at the given x- and y-coordinates with the specified width and height.

Method Summary
`void` | `add(String item)` Adds an item to this `ComboBox`.
`int` | `getSelectedIndex()` Returns the currently selected item
`String` | `getSelectedItem()` Returns the currently selected item
`boolean` | `isOpen()` Return whether this `ComboBox` is in the opened state.
`boolean` | `onKeyEvent(KeyEvent e)` Handle key events.
`void` | `paint()` Paint this `ComboBox`.
`boolean` | `remove(String item)` Removes the first occurrence of `item` from the `ComboBox`.
`String` | `select(int index)` Selects the specified item.
`void` | `setActionListener(ActionListener listener)` Sets an `ActionListener` for the `ComboBox`.
`void` | `setBounds(int x, int y, int width, int height)` Set the dimensions of this component.
`void` | `validate()` Compute this component's preferred size and assign internal values width and height.

Methods inherited from class jcontrol.ui.vole.Component
`getBounds, getParent, isVisible, onActionEvent, remove, removeFocus, requestFocus, setFont, setGraphics, setParent, setVisible, transferFocus`

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Constructor Detail

### ComboBox

    public ComboBox()

  Creates a new and empty ComboBox.

### ComboBox

    public ComboBox(int x,
                    int y)

  Constructs a new empty `ComboBox` at the given x- and y-coordinates. The preferred width and height is internally computed by taking the contained items dimensions.

  Parameters:
    `x` - The x-coordinate of this `ComboBox`.
    `y` - The y-coordinate of this `ComboBox`.

### ComboBox

    public ComboBox(String[] items,
                    int x,
                    int y)

  Constructs a new `ComboBox` with a list of items at the given x- and y-coordinates. The preferred width and height is internally computed by taking the contained items dimensions.

  Parameters:
    `items` - An array of text-items.
    `x` - The x-coordinate of this `ComboBox`.
    `y` - The y-coordinate of this `ComboBox`.

### ComboBox

    public ComboBox(String[] items,
                    int x,
                    int y,
                    int width)

  Constructs a new `ComboBox` with a list of items at the given x- and y-coordinates with the specified width and height.

  Parameters:
    `items` - An array of text-items.
    `x` - The x-coordinate of this `ComboBox`.
    `y` - The y-coordinate of this `ComboBox`.
    `width` - The width of this `ComboBox`.
    `height` - The height of this `ComboBox` in the closed state.

Method Detail

### setBounds

    public void setBounds(int x,
                          int y,
                          int width,
                          int height)

  Set the dimensions of this component. The component is repainted automatically.

  Overrides:
    `setBounds` in class `Component`
  Parameters:
    `x` - x coordinate of the upper left corner
    `y` - y coordinate of the upper left corner
    `width` - The width of this component
    `height` - The height of this component (this parameter is ignored)

### add

    public void add(String item)

  Adds an item to this `ComboBox`.

  Parameters:
    `item` - The item to add to the `ComboBox`.

### remove

    public boolean remove(String item)

  Removes the first occurrence of `item` from the `ComboBox`.

  Parameters:
    `item` - The item to remove from the `ComboBox`.
  Returns:
    Success of remove operation.

### paint

    public void paint()

  Paint this `ComboBox`.

  Overrides:
    `paint` in class `Component`

### validate

    public void validate()

  Compute this component's preferred size and assign internal values width and height.

  Overrides:
    `validate` in class `Component`

### isOpen

    public boolean isOpen()

  Return whether this `ComboBox` is in the opened state.

  Returns:
    True when the `ComboBox` is open.

### setActionListener

    public void setActionListener(ActionListener listener)

  Sets an `ActionListener` for the `ComboBox`. It will receive `ActionEvents` everytime a combo box item is pressed.

  Parameters:
    `listener` - The `ActionListener` to assign to this `ComboBox`.

### onKeyEvent

    public boolean onKeyEvent(KeyEvent e)

  Handle key events. On several user actions, an `ActionEvent` is fired.

  Overrides:
    `onKeyEvent` in class `Component`
  Parameters:
    `e` - the KeyEvent
  Returns:
    If this method returns true, the KeyEvent is handled by the super `Container`.

### select

    public String select(int index)

  Selects the specified item.

  Parameters:
    `index` - the index of the item to select
  Returns:
    String the selected item, or `null` if the index is out of range or the ComboBox was open and therefore, the item could not be selected.

### getSelectedItem

    public String getSelectedItem()

  Returns the currently selected item

  Returns:
    String the selected item

### getSelectedIndex

    public int getSelectedIndex()

  Returns the currently selected item

  Returns:
    String the selected item

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