|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.ui.vole.Component jcontrol.ui.vole.ComboBox
public class ComboBox
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.
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 |
---|
public ComboBox()
public ComboBox(int x, int y)
ComboBox
at the given
x- and y-coordinates. The preferred width and height is
internally computed by taking the contained items dimensions.
x
- The x-coordinate of this ComboBox
.y
- The y-coordinate of this ComboBox
.public ComboBox(String[] items, int x, int y)
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.
items
- An array of text-items.x
- The x-coordinate of this ComboBox
.y
- The y-coordinate of this ComboBox
.public ComboBox(String[] items, int x, int y, int width)
ComboBox
with a list of items
at the given x- and y-coordinates with the specified width and height.
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 |
---|
public void setBounds(int x, int y, int width, int height)
setBounds
in class Component
x
- x coordinate of the upper left cornery
- y coordinate of the upper left cornerwidth
- The width of this componentheight
- The height of this component (this parameter is ignored)public void add(String item)
ComboBox
.
item
- The item to add to the ComboBox
.public boolean remove(String item)
item
from the
ComboBox
.
item
- The item to remove from the ComboBox
.
public void paint()
ComboBox
.
paint
in class Component
public void validate()
validate
in class Component
public boolean isOpen()
ComboBox
is in the opened state.
ComboBox
is open.public void setActionListener(ActionListener listener)
ActionListener
for the ComboBox
. It will
receive ActionEvents
everytime a combo box item is pressed.
listener
- The ActionListener
to assign to this ComboBox
.public boolean onKeyEvent(KeyEvent e)
ActionEvent
is fired.
onKeyEvent
in class Component
e
- the KeyEvent
Container
.public String select(int index)
index
- the index of the item to select
null
if the index is out
of range or the ComboBox was open and therefore, the item could not be
selected.public String getSelectedItem()
public int getSelectedIndex()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |