public class BComboBox extends Widget
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:
Constructor and Description |
---|
BComboBox()
Create a new uneditable BComboBox containing no objects.
|
BComboBox(java.util.Collection contents)
Create a new uneditable BComboBox containing the objects in a Collection.
|
BComboBox(javax.swing.ComboBoxModel model)
Create a new uneditable BComboBox whose contents are determined by a ComboBoxModel.
|
BComboBox(java.lang.Object[] contents)
Create a new uneditable BComboBox containing the objects in an array.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
java.lang.Object o)
Add an object at specified position in the middle of the list.
|
void |
add(java.lang.Object o)
Add an object to the end of the list.
|
javax.swing.JComboBox |
getComponent()
Get the java.awt.Component corresponding to this Widget.
|
java.lang.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.
|
javax.swing.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.
|
java.lang.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,
java.lang.Object o)
Replace the object at a specified position in the list with a new one.
|
void |
setContents(java.util.Collection c)
Set the contents of the list to the objects in a Collection.
|
void |
setContents(java.lang.Object[] 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(javax.swing.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(java.lang.Object value)
Set the value shown in the combo box.
|
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
addEventLink, addEventLink, removeEventLink
public BComboBox()
public BComboBox(java.lang.Object[] contents)
public BComboBox(java.util.Collection contents)
public BComboBox(javax.swing.ComboBoxModel model)
public javax.swing.JComboBox getComponent()
Widget
getComponent
in class Widget
public boolean isEditable()
public void setEditable(boolean editable)
public void setContents(java.lang.Object[] o)
o
- the objects to put in the combo box's listpublic void setContents(java.util.Collection c)
c
- the objects to put in the combo box's listpublic javax.swing.ComboBoxModel getModel()
public void setModel(javax.swing.ComboBoxModel model)
public void add(java.lang.Object o)
o
- the object to addpublic void add(int index, java.lang.Object o)
index
- the position at which to add the objecto
- the object to addpublic void replace(int index, java.lang.Object o)
index
- the position at which to set the objecto
- the new object to addpublic void remove(int index)
index
- the position from which to remove the objectpublic void removeAll()
public int getItemCount()
public java.lang.Object getItem(int index)
public int getPreferredVisibleRows()
public void setPreferredVisibleRows(int rows)
public int getSelectedIndex()
public void setSelectedIndex(int index)
public java.lang.Object getSelectedValue()
public void setSelectedValue(java.lang.Object value)
Written by Peter Eastman.