- java.lang.Object
-
- javax.swing.AbstractListModel<E>
-
- javax.swing.DefaultComboBoxModel<E>
-
- 参数类型
-
E- 这个模型的元素的类型
- All Implemented Interfaces:
-
Serializable,ComboBoxModel<E>,ListModel<E>,MutableComboBoxModel<E>
public class DefaultComboBoxModel<E> extends AbstractListModel<E> implements MutableComboBoxModel<E>, Serializable
组合框的默认模型。- 从以下版本开始:
- 1.2
- 另请参见:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
-
构造方法摘要
构造方法 Constructor 描述 DefaultComboBoxModel()构造一个空的DefaultComboBoxModel对象。DefaultComboBoxModel(E[] items)构造一个使用对象数组初始化的DefaultComboBoxModel对象。DefaultComboBoxModel(Vector<E> v)构造一个使用向量初始化的DefaultComboBoxModel对象。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidaddElement(E anObject)在模型的末尾添加一个项目。EgetElementAt(int index)返回指定索引处的值。intgetIndexOf(Object anObject)返回列表中指定对象的索引位置。ObjectgetSelectedItem()返回所选项目intgetSize()返回列表的长度。voidinsertElementAt(E anObject, int index)在特定索引中添加项目。voidremoveAllElements()清空清单。voidremoveElement(Object anObject)从模型中删除一个项目。voidremoveElementAt(int index)删除特定索引处的项目。voidsetSelectedItem(Object anObject)设置所选项目的值。-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
-
-
-
-
构造方法详细信息
-
DefaultComboBoxModel
public DefaultComboBoxModel()
构造一个空的DefaultComboBoxModel对象。
-
DefaultComboBoxModel
public DefaultComboBoxModel(E[] items)
构造一个使用对象数组初始化的DefaultComboBoxModel对象。- 参数
-
items- 一个Object对象数组
-
-
方法详细信息
-
setSelectedItem
public void setSelectedItem(Object anObject)
设置所选项目的值。 所选项可以为空。- Specified by:
-
setSelectedItem在接口ComboBoxModel<E> - 参数
-
anObject- 无法选择的组合框值或null。
-
getSelectedItem
public Object getSelectedItem()
说明从接口ComboBoxModel复制返回所选项目- Specified by:
-
getSelectedItem在接口ComboBoxModel<E> - 结果
-
所选项目或
null如果没有选择
-
getSize
public int getSize()
描述从界面ListModel复制返回列表的长度。
-
getElementAt
public E getElementAt(int index)
说明从接口ListModel复制返回指定索引处的值。- Specified by:
-
getElementAt在接口ListModel<E> - 参数
-
index- 请求的索引 - 结果
-
价值在
index
-
getIndexOf
public int getIndexOf(Object anObject)
返回列表中指定对象的索引位置。- 参数
-
anObject- 返回索引的对象 - 结果
- 一个表示索引位置的int,其中0是第一个位置
-
addElement
public void addElement(E anObject)
描述从接口MutableComboBoxModel复制在模型的末尾添加一个项目。 此方法的实现应该通知所有已注册ListDataListener,该项目已被增补。- Specified by:
-
addElement在接口MutableComboBoxModel<E> - 参数
-
anObject- 要添加的项目
-
insertElementAt
public void insertElementAt(E anObject, int index)
说明从接口MutableComboBoxModel复制在特定索引中添加项目。 该方法的实现应通知所有已注册的项目已被添加的ListDataListener。- Specified by:
-
insertElementAt在接口MutableComboBoxModel<E> - 参数
-
anObject- 要添加的项目 -
index- 添加对象的位置
-
removeElementAt
public void removeElementAt(int index)
描述从接口MutableComboBoxModel复制删除特定索引处的项目。 此方法的实现应该通知所有已注册ListDataListener,该项目已被删除秒。- Specified by:
-
removeElementAt在接口MutableComboBoxModel<E> - 参数
-
index- 要删除的项目的位置
-
removeElement
public void removeElement(Object anObject)
说明从接口MutableComboBoxModel复制从模型中删除一个项目。 该方法的实施应通知所有已注册的ListDataListener已被删除的ListDataListener。- Specified by:
-
removeElement接口MutableComboBoxModel<E> - 参数
-
anObject- 要删除的Object
-
removeAllElements
public void removeAllElements()
清空清单。
-
-