buoy.widget
Class BComboBox
A BComboBox is a Widget that displays a popup menu with a list of objects for the user to select.
Typically the objects are Strings, but other types of objects can be used as well. Optionally,
the combo box may be made editable, so the user may type a value directly rather than selecting
one from the list. This allows arbitrary values to be entered, not just standard ones in the list.
BComboBox provides methods for adding and removing objects in the list. Alternatively, you can set
a ComboBoxModel to provide more complex behaviors.
In addition to the event types generated by all Widgets, BComboBoxes generate the following event types:
BComboBox() - Create a new uneditable BComboBox containing no objects.
|
BComboBox(ComboBoxModel model) - Create a new uneditable BComboBox whose contents are determined by a ComboBoxModel.
|
BComboBox(contents[] ) - Create a new uneditable BComboBox containing the objects in an array.
|
BComboBox(contents[] ) - Create a new uneditable BComboBox containing the objects in a Collection.
|
void | add(Object o) - Add an object to the end of the list.
|
void | add(int index, Object o) - Add an object at specified position in the middle of the list.
|
Object | getItem(int index) - Get the item at a specific position in the list.
|
int | getItemCount() - Get the number of items in the combo box's list.
|
ComboBoxModel | getModel() - Get the ComboBoxModel which controls the contents of this BComboBox.
|
int | getPreferredVisibleRows() - Get the preferred number of rows which should be visible in the popup menu without using
a scrollbar.
|
int | getSelectedIndex() - Get the index of the selected item.
|
Object | getSelectedValue() - Get the current value which has been selected from the list or, if this is an editable combo
box, typed into the box.
|
boolean | isEditable() - Get whether this combo box is editable, allowing the user to type in values other than those in
the popup list.
|
void | remove(int index) - Remove an object from the list.
|
void | removeAll() - Remove all objects from the list.
|
void | replace(int index, Object o) - Replace the object at a specified position in the list with a new one.
|
void | setContents(Collection c) - Set the contents of the list to the objects in a Collection.
|
void | setContents(o[] ) - Set the contents of the list to the objects in an array.
|
void | setEditable(boolean editable) - Set whether this combo box is editable, allowing the user to type in values other than those in
the popup list.
|
void | setModel(ComboBoxModel model) - Set the ComboBoxModel which controls the contents of this BComboBox.
|
void | setPreferredVisibleRows(int rows) - Get the preferred number of rows which should be visible in the popup menu without using
a scrollbar.
|
void | setSelectedIndex(int index) - Select the item with the specified index.
|
void | setSelectedValue(Object value) - Set the value shown in the combo box.
|
addEventLink , dispatchEvent , getBackground , getBounds , getComponent , getCursor , getFont , getMaximumSize , getMinimumSize , getName , getParent , getPreferredSize , hasFocus , isEnabled , isFocusable , isVisible , repaint , requestFocus , setBackground , setCursor , setEnabled , setFocusable , setFont , setName , setVisible |
BComboBox
public BComboBox()
Create a new uneditable BComboBox containing no objects.
BComboBox
public BComboBox(ComboBoxModel model)
Create a new uneditable BComboBox whose contents are determined by a ComboBoxModel.
BComboBox
public BComboBox(contents[] )
Create a new uneditable BComboBox containing the objects in an array.
BComboBox
public BComboBox(contents[] )
Create a new uneditable BComboBox containing the objects in a Collection. The objects will be
added in the order they are returned by the Collection's Iterator.
add
public void add(Object o)
Add an object to the end of the list.
add
public void add(int index,
Object o)
Add an object at specified position in the middle of the list.
index
- the position at which to add the objecto
- the object to add
getItem
public Object getItem(int index)
Get the item at a specific position in the list.
getItemCount
public int getItemCount()
Get the number of items in the combo box's list.
getModel
public ComboBoxModel getModel()
Get the ComboBoxModel which controls the contents of this BComboBox.
getPreferredVisibleRows
public int getPreferredVisibleRows()
Get the preferred number of rows which should be visible in the popup menu without using
a scrollbar.
getSelectedIndex
public int getSelectedIndex()
Get the index of the selected item. If this is an editable combo box and the current value
is not in the list, this returns -1.
getSelectedValue
public Object getSelectedValue()
Get the current value which has been selected from the list or, if this is an editable combo
box, typed into the box.
isEditable
public boolean isEditable()
Get whether this combo box is editable, allowing the user to type in values other than those in
the popup list.
remove
public void remove(int index)
Remove an object from the list.
index
- the position from which to remove the object
removeAll
public void removeAll()
Remove all objects from the list.
replace
public void replace(int index,
Object o)
Replace the object at a specified position in the list with a new one.
index
- the position at which to set the objecto
- the new object to add
setContents
public void setContents(Collection c)
Set the contents of the list to the objects in a Collection. This completely replaces the contents of the
list, removing any objects that were previously in it. The objects will be added in the order they are
returned by the Collection's Iterator.
c
- the objects to put in the combo box's list
setContents
public void setContents(o[] )
Set the contents of the list to the objects in an array. This completely replaces the contents of the
list, removing any objects that were previously in it.
setEditable
public void setEditable(boolean editable)
Set whether this combo box is editable, allowing the user to type in values other than those in
the popup list.
setModel
public void setModel(ComboBoxModel model)
Set the ComboBoxModel which controls the contents of this BComboBox.
setPreferredVisibleRows
public void setPreferredVisibleRows(int rows)
Get the preferred number of rows which should be visible in the popup menu without using
a scrollbar.
setSelectedIndex
public void setSelectedIndex(int index)
Select the item with the specified index.
setSelectedValue
public void setSelectedValue(Object value)
Set the value shown in the combo box. If this combo box is not editable and the specified value
is not a member of the list, this will have no effect.
Written by Peter Eastman.