java.lang.Objectjavax.swing.AbstractListModel
javax.swing.DefaultComboBoxModel
public class DefaultComboBoxModel
组合框的默认模型。
| 字段摘要 |
|---|
| 从类 javax.swing.AbstractListModel 继承的字段 |
|---|
listenerList |
| 构造方法摘要 | |
|---|---|
DefaultComboBoxModel() 构造一个空的 DefaultComboBoxModel 对象。 |
|
DefaultComboBoxModel(Object[] items) 构造一个用对象数组初始化的 DefaultComboBoxModel 对象。 |
|
DefaultComboBoxModel(Vector<?> v) 构造一个用向量初始化的 DefaultComboBoxModel 对象。 |
|
| 方法摘要 | |
|---|---|
void |
addElement(Object anObject) 在模型的末尾添加项。 |
Object |
getElementAt(int index) 返回指定索引处的值。 |
int |
getIndexOf(Object anObject) 返回指定对象在列表中的索引位置。 |
Object |
getSelectedItem() 返回选择的项 |
int |
getSize() 返回列表的长度。 |
void |
insertElementAt(Object anObject, int index) 在指定索引处添加项。 |
void |
removeAllElements() 清空列表。 |
void |
removeElement(Object anObject) 从模型中移除项。 |
void |
removeElementAt(int index) 在指定索引处移除项。 |
void |
setSelectedItem(Object anObject) 设置选择项的值。 |
| 从类 javax.swing.AbstractListModel 继承的方法 |
|---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 从接口 javax.swing.ListModel 继承的方法 |
|---|
addListDataListener, removeListDataListener |
| 构造方法详细信息 |
|---|
public DefaultComboBoxModel()
public DefaultComboBoxModel(Object[] items)
items - Object 对象数组
public DefaultComboBoxModel(Vector<?> v)
v - 一个 Vector 对象
| 方法详细信息 |
|---|
public void setSelectedItem(Object anObject)
ComboBoxModel 中的
setSelectedItem
anObject - 组合框值,如果没有选择任何对象,则该参数为 null。
public Object getSelectedItem()
ComboBoxModel 复制的描述
ComboBoxModel 中的
getSelectedItem
null
public int getSize()
public Object getElementAt(int index)
ListModel 复制的描述
ListModel 中的
getElementAt
index - 请求的索引
index 处的值
public int getIndexOf(Object anObject)
anObject -
public void addElement(Object anObject)
MutableComboBoxModel 复制的描述
ListDataListener。
MutableComboBoxModel 中的
addElement
anObject - 要添加的
Object
public void insertElementAt(Object anObject, int index)
MutableComboBoxModel 复制的描述
ListDataListener。
MutableComboBoxModel 中的
insertElementAt
anObject - 要添加的
Object
index - 添加对象的位置
public void removeElementAt(int index)
MutableComboBoxModel 复制的描述
ListDataListener。
MutableComboBoxModel 中的
removeElementAt
index - 要移除对象的位置
public void removeElement(Object anObject)
MutableComboBoxModel 复制的描述
ListDataListener。
MutableComboBoxModel 中的
removeElement
anObject - 要移除的
Object
public void removeAllElements()