|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
public class JComboBox
将按钮或可编辑字段与下拉列表组合的组件。用户可以从下拉列表中选择值,下拉列表在用户请求时显示。如果使组合框处于可编辑状态,则组合框将包括用户可在其中键入值的可编辑字段。
警告:Swing 不是线程安全的。有关更多信息,请参阅 Swing's Threading Policy。
警告:此类的序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
有关更多信息,请参阅 The Java Tutorial 中的 How to Use Combo Boxes 一节。
ComboBoxModel,
DefaultComboBoxModel
| 嵌套类摘要 | |
|---|---|
protected class |
JComboBox.AccessibleJComboBox 此类实现 JComboBox 类的可访问性支持。 |
static interface |
JComboBox.KeySelectionManager 定义 KeySelectionManager 的接口。 |
| 从类 javax.swing.JComponent 继承的嵌套类/接口 |
|---|
JComponent.AccessibleJComponent |
| 从类 java.awt.Container 继承的嵌套类/接口 |
|---|
Container.AccessibleAWTContainer |
| 从类 java.awt.Component 继承的嵌套类/接口 |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| 字段摘要 | |
|---|---|
protected String |
actionCommand 此受保护字段是特定于实现的。 |
protected ComboBoxModel |
dataModel 此受保护字段是特定于实现的。 |
protected ComboBoxEditor |
editor 此受保护字段是特定于实现的。 |
protected boolean |
isEditable 此受保护字段是特定于实现的。 |
protected JComboBox.KeySelectionManager |
keySelectionManager 此受保护字段是特定于实现的。 |
protected boolean |
lightWeightPopupEnabled 此受保护字段是特定于实现的。 |
protected int |
maximumRowCount 此受保护字段是特定于实现的。 |
protected ListCellRenderer |
renderer 此受保护字段是特定于实现的。 |
protected Object |
selectedItemReminder 此受保护字段是特定于实现的。 |
| 从类 javax.swing.JComponent 继承的字段 |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| 从类 java.awt.Component 继承的字段 |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| 从接口 java.awt.image.ImageObserver 继承的字段 |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| 构造方法摘要 | |
|---|---|
JComboBox() 创建具有默认数据模型的 JComboBox。 |
|
JComboBox(ComboBoxModel aModel) 创建一个 JComboBox,其项取自现有的 ComboBoxModel。 |
|
JComboBox(Object[] items) 创建包含指定数组中的元素的 JComboBox。 |
|
JComboBox(Vector<?> items) 创建包含指定 Vector 中的元素的 JComboBox。 |
|
| 方法摘要 | |
|---|---|
void |
actionPerformed(ActionEvent e) 此方法由于实现的副作用而存在的公共方法。 |
protected void |
actionPropertyChanged(Action action, String propertyName) 更新组合框的状态以响应关联动作中的属性更改。 |
void |
addActionListener(ActionListener l) 添加 ActionListener。 |
void |
addItem(Object anObject) 为项列表添加项。 |
void |
addItemListener(ItemListener aListener) 添加 ItemListener。 |
void |
addPopupMenuListener(PopupMenuListener l) 添加 PopupMenu 侦听器,该侦听器将侦听取自组合框弹出部分的通知消息。 |
void |
configureEditor(ComboBoxEditor anEditor, Object anItem) 利用指定项初始化编辑器。 |
protected void |
configurePropertiesFromAction(Action a) 在此组合框上设置属性以匹配指定 Action 中的属性。 |
void |
contentsChanged(ListDataEvent e) 此方法作为实现的副作用存在的公共方法。 |
protected PropertyChangeListener |
createActionPropertyChangeListener(Action a) 创建并返回一个 PropertyChangeListener,它负责侦听指定 Action 的更改并更新适当属性。 |
protected JComboBox.KeySelectionManager |
createDefaultKeySelectionManager() 返回默认键选择管理器的实例。 |
protected void |
fireActionEvent() 通知所有需要此事件类型的通知的已注册侦听器。 |
protected void |
fireItemStateChanged(ItemEvent e) 通知所有需要此事件类型的通知的已注册侦听器。 |
void |
firePopupMenuCanceled() 通知 PopupMenuListener 组合框的弹出部分已被取消。 |
void |
firePopupMenuWillBecomeInvisible() 通知 PopupMenuListener 组合框的弹出部分已变得不可见。 |
void |
firePopupMenuWillBecomeVisible() 通知 PopupMenuListener 组合框的弹出部分将变得可见。 |
AccessibleContext |
getAccessibleContext() 获取与此 JComboBox 关联的 AccessibleContext。 |
Action |
getAction() 返回此 ActionEvent 源当前设置的 Action,如果没有设置任何 Action,则返回 null。 |
String |
getActionCommand() 返回发送到动作侦听器的事件中包括的动作命令。 |
ActionListener[] |
getActionListeners() 返回使用 addActionListener() 添加到此 JComboBox 的所有 ActionListener 组成的数组。 |
ComboBoxEditor |
getEditor() 返回用于绘制和编辑 JComboBox 字段中所选项的编辑器。 |
Object |
getItemAt(int index) 返回指定索引处的列表项。 |
int |
getItemCount() 返回列表中的项数。 |
ItemListener[] |
getItemListeners() 返回使用 addItemListener() 添加到此 JComboBox 中的所有 ItemListener 组成的数组。 |
JComboBox.KeySelectionManager |
getKeySelectionManager() 返回列表的键选择管理器。 |
int |
getMaximumRowCount() 返回组合框不使用滚动条可以显示的最大项数 |
ComboBoxModel |
getModel() 返回 JComboBox 当前使用的数据模型。 |
PopupMenuListener[] |
getPopupMenuListeners() 返回利用 addPopupMenuListener() 添加到此 JComboBox 的所有 PopupMenuListener 组成的数组。 |
Object |
getPrototypeDisplayValue() 返回“原型显示”值,即用于计算显示高度和宽度的 Object。 |
ListCellRenderer |
getRenderer() 返回用于显示 JComboBox 字段中所选项的渲染器。 |
int |
getSelectedIndex() 返回列表中与给定项匹配的第一个选项。 |
Object |
getSelectedItem() 返回当前所选项。 |
Object[] |
getSelectedObjects() 返回包含所选项的数组。 |
ComboBoxUI |
getUI() 返回呈现此组件的 L&F 对象。 |
String |
getUIClassID() 返回呈现此组件的 L&F 类的名称。 |
void |
hidePopup() 促使组合框关闭其弹出窗口。 |
void |
insertItemAt(Object anObject, int index) 在项列表中的给定索引处插入项。 |
protected void |
installAncestorListener() |
void |
intervalAdded(ListDataEvent e) 此方法作为实现的副作用存在的公共方法。 |
void |
intervalRemoved(ListDataEvent e) 此方法作为实现的副作用存在的公共方法。 |
boolean |
isEditable() 如果 JComboBox 可编辑,则返回 true。 |
boolean |
isLightWeightPopupEnabled() 获取 lightWeightPopupEnabled 属性的值。 |
boolean |
isPopupVisible() 确定弹出窗口的可见性。 |
protected String |
paramString() 返回此 JComboBox 的字符串表示形式。 |
void |
processKeyEvent(KeyEvent e) 处理 KeyEvent,查找 Tab 键。 |
void |
removeActionListener(ActionListener l) 移除 ActionListener。 |
void |
removeAllItems() 从项列表中移除所有项。 |
void |
removeItem(Object anObject) 从项列表中移除项。 |
void |
removeItemAt(int anIndex) 移除 anIndex 处的项。 |
void |
removeItemListener(ItemListener aListener) 移除 ItemListener。 |
void |
removePopupMenuListener(PopupMenuListener l) 移除 PopupMenuListener。 |
protected void |
selectedItemChanged() 此受保护方法是特定于实现的。 |
boolean |
selectWithKeyChar(char keyChar) 如果存在与指定键盘字符相对应的项,则选择该列表项并返回 true。 |
void |
setAction(Action a) 设置 ActionEvent 源的 Action。 |
void |
setActionCommand(String aCommand) 设置发送到动作侦听器的事件中应该包括的动作命令。 |
void |
setEditable(boolean aFlag) 确定 JComboBox 字段是否可编辑。 |
void |
setEditor(ComboBoxEditor anEditor) 设置用于绘制和编辑 JComboBox 字段中所选项的编辑器。 |
void |
setEnabled(boolean b) 启用组合框以便可以选择项。 |
void |
setKeySelectionManager(JComboBox.KeySelectionManager aManager) 设置将键盘字符转换为列表选择的对象。 |
void |
setLightWeightPopupEnabled(boolean aFlag) 设置 lightWeightPopupEnabled 属性,该属性提供一个提示:是应该使用重量级 Component(如 Panel 或 Window)还是轻量级 Component 来包含 JComboBox。 |
void |
setMaximumRowCount(int count) 设置 JComboBox 显示的最大行数。 |
void |
setModel(ComboBoxModel aModel) 设置 JComboBox 用于获取项列表的数据模型。 |
void |
setPopupVisible(boolean v) 设置弹出窗口的可见性。 |
void |
setPrototypeDisplayValue(Object prototypeDisplayValue) 设置用于计算 UI 部分的显示大小的原型显示值。 |
void |
setRenderer(ListCellRenderer aRenderer) 设置渲染器,该渲染器用于绘制列表项和从 JComboBox 字段的列表中选择的项。 |
void |
setSelectedIndex(int anIndex) 选择索引 anIndex 处的项。 |
void |
setSelectedItem(Object anObject) 将组合框显示区域中所选项设置为参数中的对象。 |
void |
setUI(ComboBoxUI ui) 设置呈现此组件的 L&F 对象。 |
void |
showPopup() 促使组合框显示其弹出窗口。 |
void |
updateUI() 将 UI 属性重置为当前外观的值。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 字段详细信息 |
|---|
protected ComboBoxModel dataModel
getModel(),
setModel(javax.swing.ComboBoxModel)
protected ListCellRenderer renderer
getRenderer(),
setRenderer(javax.swing.ListCellRenderer)
protected ComboBoxEditor editor
getEditor(),
setEditor(javax.swing.ComboBoxEditor)
protected int maximumRowCount
getMaximumRowCount(),
setMaximumRowCount(int)
protected boolean isEditable
isEditable,
setEditable(boolean)
protected JComboBox.KeySelectionManager keySelectionManager
setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager),
getKeySelectionManager()
protected String actionCommand
setActionCommand(java.lang.String),
getActionCommand()
protected boolean lightWeightPopupEnabled
setLightWeightPopupEnabled(boolean),
isLightWeightPopupEnabled()
protected Object selectedItemReminder
| 构造方法详细信息 |
|---|
public JComboBox(ComboBoxModel aModel)
JComboBox,其项取自现有的
ComboBoxModel。由于提供了
ComboBoxModel,使用此构造方法创建的组合框不创建默认组合框模型,这可能影响插入、移除和添加方法的行为方式。
aModel - 提供显示的项列表的
ComboBoxModel
DefaultComboBoxModel
public JComboBox(Object[] items)
JComboBox。默认情况下,选择数组中的第一项(因而也选择了该项的数据模型)。
items - 要插入到组合框的对象数组
DefaultComboBoxModel
public JComboBox(Vector<?> items)
JComboBox。默认情况下,选择数组中的第一项(因而也选择了该项的数据模型)。
items - 要插入到组合框的向量数组
DefaultComboBoxModel
public JComboBox()
JComboBox。默认的数据模型为空对象列表。使用
addItem 添加项。默认情况下,选择数据模型中的第一项。
DefaultComboBoxModel
| 方法详细信息 |
|---|
protected void installAncestorListener()
public void setUI(ComboBoxUI ui)
ui -
ComboBoxUI L&F 对象
UIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
JComponent 中的
updateUI
JComponent.updateUI()
public String getUIClassID()
JComponent 中的
getUIClassID
JComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)
public ComboBoxUI getUI()
public void setModel(ComboBoxModel aModel)
JComboBox 用于获取项列表的数据模型。
aModel - 提供显示的项列表的
ComboBoxModel
public ComboBoxModel getModel()
JComboBox 当前使用的数据模型。
ComboBoxModel
public void setLightWeightPopupEnabled(boolean aFlag)
lightWeightPopupEnabled 属性,该属性提供一个提示:是应该使用重量级
Component(如
Panel 或
Window)还是轻量级
Component 来包含
JComboBox。使用轻量级还是重量级组件,最终由
JComboBox 决定。轻量级窗口比重量级窗口更有效,但是轻量级和重量级组件在 GUI 中不能很好地混合使用。如果应用程序混合使用轻量级和重量级组件,则应该禁用轻量级弹出窗口。除非由外观另行指定,否则
lightWeightPopupEnabled 属性的默认值为
true。某些外观始终使用重量级弹出窗口,不管此属性的值如何。
请参阅 The Swing Connection 上的文章 Mixing Heavy and Light Components。此方法触发属性更改事件。
aFlag - 如果为
true,则需要轻量级弹出窗口
public boolean isLightWeightPopupEnabled()
lightWeightPopupEnabled 属性的值。
lightWeightPopupEnabled 属性的值
setLightWeightPopupEnabled(boolean)
public void setEditable(boolean aFlag)
JComboBox 字段是否可编辑。可编辑的
JComboBox 允许用户在字段中键入内容或者从列表中选择项来初始化字段,执行此操作后,该字段就可编辑了。(编辑仅影响字段,列表项保持原样。)不可编辑的
JComboBox 在字段中显示所选项,但不能修改该选择。
aFlag - 一个 boolean 值,其中 true 指示字段可编辑。
public boolean isEditable()
JComboBox 可编辑,则返回 true。默认情况下,组合框不可编辑。
JComboBox 可编辑,则返回 true;否则返回 false
public void setMaximumRowCount(int count)
JComboBox 显示的最大行数。如果模型中的对象数大于 count,则组合框使用滚动条。
count - 一个整数,它指定使用滚动条前要在列表中显示的最大项数
public int getMaximumRowCount()
public void setRenderer(ListCellRenderer aRenderer)
默认渲染器显示字符串或图标。其他渲染器可处理图形图像和复合选项。
要显示所选项,请调用 aRenderer.getListCellRendererComponent,其中传递列表对象和索引 -1。
aRenderer - 显示所选项的
ListCellRenderer
setEditor(javax.swing.ComboBoxEditor)
public ListCellRenderer getRenderer()
JComboBox 字段中所选项的渲染器。
ListCellRenderer。
public void setEditor(ComboBoxEditor anEditor)
JComboBox 字段中所选项的编辑器。仅当接收的
JComboBox 可编辑时才使用编辑器。如果不可编辑,则组合框使用渲染器绘制所选项。
anEditor - 显示所选项的
ComboBoxEditor
setRenderer(javax.swing.ListCellRenderer)
public ComboBoxEditor getEditor()
JComboBox 字段中所选项的编辑器。
ComboBoxEditor。
public void setSelectedItem(Object anObject)
anObject 在列表中,则显示区域显示所选的
anObject。
如果 anObject 不 在列表中,且组合框不可编辑,则不会更改显示区域中的当前选择。对于可编辑的组合框,选择将更改为 anObject。
如果此操作造成所选项发生更改,则添加到组合框的 ItemListener 将获得一个或两个 ItemEvent 通知。如果有当前所选项,则将触发 ItemEvent,而状态更改将为 ItemEvent.DESELECTED。如果 anObject 在列表中,但不是当前选择的项,则将触发 ItemEvent,而状态更改将为 ItemEvent.SELECTED。
调用此方法时,添加到组合框的 ActionListener 将获得 ActionEvent 通知。
anObject - 要选择的列表对象;使用
null 清除选择
public Object getSelectedItem()
如果组合框可编辑,则可能尚未使用 addItem、insertItemAt 或数据构造方法将此值添加到组合框中。
setSelectedItem(java.lang.Object)
public void setSelectedIndex(int anIndex)
anIndex 处的项。
anIndex - 指定要选择的列表项的整数,其中 0 指定列表中的第一项,-1 指示没有作出选择
IllegalArgumentException - 如果
anIndex < -1 或者
anIndex 大于等于列表大小
public int getSelectedIndex()
JComboBox 允许选择不在列表中的项,则结果并非不总是确定的。如果不存在所选项或者用户指定的项不在列表中,则返回 -1。
public Object getPrototypeDisplayValue()
prototypeDisplayValue 属性的值
setPrototypeDisplayValue(java.lang.Object)
public void setPrototypeDisplayValue(Object prototypeDisplayValue)
如果指定了原型显示值,则组合框首选大小的计算方式是:利用原型显示值配置渲染器,然后获取其首选大小。指定首选显示值在组合框将显示大量数据时往往很有用。如果没有指定原型显示值,则必须为模型中的每个值及其获取的首选大小配置渲染器,其花费相对昂贵。
prototypeDisplayValue -
getPrototypeDisplayValue()
public void addItem(Object anObject)
JComboBox 使用可变数据模型时此方法才有效。
警告:如果添加复制的 String 对象,可能会发生焦点和键盘导航问题。解决方法是,添加新对象而不是 String 对象,并且确保定义了 toString() 方法。例如:
comboBox.addItem(makeObj("Item 1"));
comboBox.addItem(makeObj("Item 1"));
...
private Object makeObj(final String item) {
return new Object() { public String toString() { return item; } };
}
anObject - 要添加到列表的 Object
MutableComboBoxModel
public void insertItemAt(Object anObject,
int index)
JComboBox 使用可变数据模型时此方法才有效。
anObject - 要添加到列表的
Object
index - 指定添加项的位置的整数
MutableComboBoxModel
public void removeItem(Object anObject)
JComboBox 使用可变数据模型时此方法才有效。
anObject - 要从项列表中移除的对象
MutableComboBoxModel
public void removeItemAt(int anIndex)
anIndex 处的项。仅当
JComboBox 使用可变数据模型时此方法才有效。
anIndex - 指定要移除的项索引的 int,其中 0 指示列表中的第一项
MutableComboBoxModel
public void removeAllItems()
public void showPopup()
setPopupVisible(boolean)
public void hidePopup()
setPopupVisible(boolean)
public void setPopupVisible(boolean v)
public boolean isPopupVisible()
public void addItemListener(ItemListener aListener)
ItemListener。
当所选项更改时,aListener 将接收一个或两个 ItemEvent。
ItemSelectable 中的
addItemListener
aListener - 要通知的
ItemListener
setSelectedItem(java.lang.Object)
public void removeItemListener(ItemListener aListener)
ItemListener。
ItemSelectable 中的
removeItemListener
aListener - 要移除的
ItemListener
ItemEvent
public ItemListener[] getItemListeners()
ItemListener 组成的数组。
ItemListener,如果没有添加侦听器,则返回一个空数组
public void addActionListener(ActionListener l)
ActionListener。
当作出选择时,ActionListener 将接收一个 ActionEvent。如果组合框可编辑,则在编辑停止时将触发 ActionEvent。
l - 要通知的
ActionListener
setSelectedItem(java.lang.Object)
public void removeActionListener(ActionListener l)
ActionListener。
l - 要移除的
ActionListener
public ActionListener[] getActionListeners()
ActionListener 组成的数组。
ActionListener;如果没有添加侦听器,则返回一个空数组
public void addPopupMenuListener(PopupMenuListener l)
PopupMenu 侦听器,该侦听器将侦听取自组合框弹出部分的通知消息。
对于 Java 附带的所有标准外观,组合框的弹出列表部分将被实现为 JPopupMenu。自定义外观可能不以这种方式实现组合框的弹出列表部分,因此不接收通知。
l - 要添加的
PopupMenuListener
public void removePopupMenuListener(PopupMenuListener l)
PopupMenuListener。
l - 要移除的
PopupMenuListener
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public PopupMenuListener[] getPopupMenuListeners()
PopupMenuListener 组成的数组。
PopupMenuListener,如果没有添加侦听器,则返回一个空数组
public void firePopupMenuWillBecomeVisible()
PopupMenuListener 组合框的弹出部分将变得可见。
此方法是公共方法,但只能由 UI 委托调用。
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public void firePopupMenuWillBecomeInvisible()
PopupMenuListener 组合框的弹出部分已变得不可见。
此方法是公共方法,但只能由 UI 委托调用。
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public void firePopupMenuCanceled()
PopupMenuListener 组合框的弹出部分已被取消。
此方法是公共方法,但只能由 UI 委托调用。
addPopupMenuListener(javax.swing.event.PopupMenuListener)
public void setActionCommand(String aCommand)
aCommand - 包含发送到动作侦听器的“命令”的字符串;根据其所接受的命令,相同的侦听器可以做不同的事情
public String getActionCommand()
public void setAction(Action a)
ActionEvent 源的
Action。新的
Action 替换以前设置的所有
Action,而不影响通过
addActionListener 独立添加的
ActionListener。如果
Action 已经是一个注册到
ActionEvent 源的
ActionListener,则不对它进行重新注册。
设置 Action 将导致立即更改支持 Action 的 Swing 组件中所描述的所有属性。随后,组合框的属性将随 Action 属性的更改自动更新。
此方法使用三个其他方法来设置和帮助跟踪 Action 的属性值。它使用 configurePropertiesFromAction 方法立即更改组合框的属性。要跟踪 Action 属性值的更改,此方法应注册 createActionPropertyChangeListener 所返回的 PropertyChangeListener。当 Action 中的属性更改时,默认 PropertyChangeListener 调用 actionPropertyChanged 方法。
a -
JComboBox 的
Action,或者
null。
Action,
getAction(),
configurePropertiesFromAction(javax.swing.Action),
createActionPropertyChangeListener(javax.swing.Action),
actionPropertyChanged(javax.swing.Action, java.lang.String)
public Action getAction()
ActionEvent 源当前设置的
Action,如果没有设置任何
Action,则返回
null。
ActionEvent 源的
Action;或者
null
Action,
setAction(javax.swing.Action)
protected void configurePropertiesFromAction(Action a)
Action 中的属性。有关设置何种属性的更多信息,请参阅
支持 Action 的 Swing 组件。
a - 从其获取属性的
Action,或者
null
Action,
setAction(javax.swing.Action)
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
PropertyChangeListener,它负责侦听指定
Action 的更改并更新适当属性。
警告:如果子类化此方法,则不要创建匿名内部类。如果执行组合框的生存期,则它将被绑定到 Action 的生存期。
a - 组合框的动作
Action,
setAction(javax.swing.Action)
protected void actionPropertyChanged(Action action,
String propertyName)
createActionPropertyChangeListener 所返回的
PropertyChangeListener 中调用此方法。子类通常不需要调用此方法。支持其他
Action 属性的子类应该重写此方法和
configurePropertiesFromAction。
有关此方法设置的属性列表,请参阅支持的 Action 的 Swing 组件下的表。
action - 与此组合框关联的
Action
propertyName - 更改的属性名称
Action,
configurePropertiesFromAction(javax.swing.Action)
protected void fireItemStateChanged(ItemEvent e)
e - 需要的事件
EventListenerList
protected void fireActionEvent()
EventListenerList
protected void selectedItemChanged()
public Object[] getSelectedObjects()
ItemSelectable 兼容。
ItemSelectable 中的
getSelectedObjects
Object 数组
public void actionPerformed(ActionEvent e)
ActionListener 中的
actionPerformed
public void contentsChanged(ListDataEvent e)
ListDataListener 中的
contentsChanged
e - 封装事件信息的
ListDataEvent
public void intervalAdded(ListDataEvent e)
ListDataListener 中的
intervalAdded
e - 封装事件信息的
ListDataEvent
public void intervalRemoved(ListDataEvent e)
ListDataListener 中的
intervalRemoved
e - 封装事件信息的
ListDataEvent
public boolean selectWithKeyChar(char keyChar)
keyChar - 一个 char,它通常是用户键入的键盘键
public void setEnabled(boolean b)
JComponent 中的
setEnabled
b - 一个 boolean 值,为 true 时,启用该组件,为 false 时,禁用该组件
Component.isEnabled(),
Component.isLightweight()
public void configureEditor(ComboBoxEditor anEditor,
Object anItem)
anEditor - 显示组合框字段中的列表项,并可以对其进行编辑的
ComboBoxEditor
anItem - 要在字段中显示和编辑的对象
public void processKeyEvent(KeyEvent e)
KeyEvent,查找 Tab 键。如果找不到 Tab 键,则关闭弹出窗口。
JComponent 中的
processKeyEvent
e - 包含按下的键盘键的
KeyEvent
KeyEvent,
KeyListener,
KeyboardFocusManager,
DefaultKeyboardFocusManager,
Component.processEvent(java.awt.AWTEvent),
Component.dispatchEvent(java.awt.AWTEvent),
Component.addKeyListener(java.awt.event.KeyListener),
Component.enableEvents(long),
Component.isShowing()
public void setKeySelectionManager(JComboBox.KeySelectionManager aManager)
public JComboBox.KeySelectionManager getKeySelectionManager()
KeySelectionManager
public int getItemCount()
public Object getItemAt(int index)
index 超出范围(小于零或者大于等于列表大小),则返回
null。
index - 指示列表位置的整数,其中第一项从零开始
Object;如果超出范围,则返回
null
protected JComboBox.KeySelectionManager createDefaultKeySelectionManager()
KeySelectionManager
setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager)
protected String paramString()
JComboBox 的字符串表示形式。此方法仅在进行调试时使用,对于各个实现,所返回字符串的内容和格式可能有所不同。返回的字符串可以为空,但不可以为
null。
JComponent 中的
paramString
JComboBox 的字符串表示形式
public AccessibleContext getAccessibleContext()
Accessible 中的
getAccessibleContext
JComponent 中的
getAccessibleContext
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。