|
JavaTM 2 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 - 提供顯示的項列表的 ComboBoxModelDefaultComboBoxModelpublic JComboBox(Object[] items)
JComboBox。預設情況下,選擇陣列中的第一項(因而也選擇了該項的資料模型)。
items - 要插入到組合框的物件陣列DefaultComboBoxModelpublic JComboBox(Vector<?> items)
JComboBox。預設情況下,選擇陣列中的第一項(因而也選擇了該項的資料模型)。
items - 要插入到組合框的向量陣列DefaultComboBoxModelpublic 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 中的 updateUIJComponent.updateUI()public String getUIClassID()
JComponent 中的 getUIClassIDJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)public ComboBoxUI getUI()
public void setModel(ComboBoxModel aModel)
JComboBox 用於獲取項列表的資料模型。
aModel - 提供顯示的項列表的 ComboBoxModelpublic ComboBoxModel getModel()
JComboBox 當前使用的資料模型。
ComboBoxModelpublic 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;否則返回 falsepublic void setMaximumRowCount(int count)
JComboBox 顯示的最大行數。如果模型中的物件數大於 count,則組合框使用滾動條。
count - 一個整數,它指定使用滾動條前要在列表中顯示的最大項數public int getMaximumRowCount()
public void setRenderer(ListCellRenderer aRenderer)
預設渲染器顯示字元串或圖標。其他渲染器可處理圖形圖像和復合選項。
要顯示所選項,請調用 aRenderer.getListCellRendererComponent,其中傳遞列表物件和索引 -1。
aRenderer - 顯示所選項的 ListCellRenderersetEditor(javax.swing.ComboBoxEditor)public ListCellRenderer getRenderer()
JComboBox 欄位中所選項的渲染器。
ListCellRenderer。public void setEditor(ComboBoxEditor anEditor)
JComboBox 欄位中所選項的編輯器。僅當接收的 JComboBox 可編輯時才使用編輯器。如果不可編輯,則組合框使用渲染器繪製所選項。
anEditor - 顯示所選項的 ComboBoxEditorsetRenderer(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 - 要添加到列表的 ObjectMutableComboBoxModel
public void insertItemAt(Object anObject,
int index)
JComboBox 使用可變資料模型時此方法才有效。
anObject - 要添加到列表的 Objectindex - 指定添加項的位置的整數MutableComboBoxModelpublic void removeItem(Object anObject)
JComboBox 使用可變資料模型時此方法才有效。
anObject - 要從項列表中移除的物件MutableComboBoxModelpublic void removeItemAt(int anIndex)
anIndex 處的項。僅當 JComboBox 使用可變資料模型時此方法才有效。
anIndex - 指定要移除的項索引的 int,其中 0 指示列表中的第一項MutableComboBoxModelpublic 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 中的 addItemListeneraListener - 要通知的 ItemListenersetSelectedItem(java.lang.Object)public void removeItemListener(ItemListener aListener)
ItemListener。
ItemSelectable 中的 removeItemListeneraListener - 要移除的 ItemListenerItemEventpublic ItemListener[] getItemListeners()
ItemListener 組成的陣列。
ItemListener,如果沒有添加偵聽器,則返回一個空陣列public void addActionListener(ActionListener l)
ActionListener。
當作出選擇時,ActionListener 將接收一個 ActionEvent。如果組合框可編輯,則在編輯停止時將觸發 ActionEvent。
l - 要通知的 ActionListenersetSelectedItem(java.lang.Object)public void removeActionListener(ActionListener l)
ActionListener。
l - 要移除的 ActionListenerpublic ActionListener[] getActionListeners()
ActionListener 組成的陣列。
ActionListener;如果沒有添加偵聽器,則返回一個空陣列public void addPopupMenuListener(PopupMenuListener l)
PopupMenu 偵聽器,該偵聽器將偵聽取自組合框彈出部分的通知訊息。
對於 Java 附帶的所有標準外觀,組合框的彈出列表部分將被實作為 JPopupMenu。自定義外觀可能不以這種方式實作組合框的彈出列表部分,因此不接收通知。
l - 要添加的 PopupMenuListenerpublic void removePopupMenuListener(PopupMenuListener l)
PopupMenuListener。
l - 要移除的 PopupMenuListeneraddPopupMenuListener(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;或者 nullAction,
setAction(javax.swing.Action)protected void configurePropertiesFromAction(Action a)
Action 中的屬性。有關設置何種屬性的更多資訊,請參閱支持 Action 的 Swing 元件。
a - 從其獲取屬性的 Action,或者 nullAction,
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 - 與此組合框關聯的 ActionpropertyName - 更改的屬性名稱Action,
configurePropertiesFromAction(javax.swing.Action)protected void fireItemStateChanged(ItemEvent e)
e - 需要的事件EventListenerListprotected void fireActionEvent()
EventListenerListprotected void selectedItemChanged()
public Object[] getSelectedObjects()
ItemSelectable 相容。
ItemSelectable 中的 getSelectedObjectsObject 陣列public void actionPerformed(ActionEvent e)
ActionListener 中的 actionPerformedpublic void contentsChanged(ListDataEvent e)
ListDataListener 中的 contentsChangede - 封裝事件資訊的 ListDataEventpublic void intervalAdded(ListDataEvent e)
ListDataListener 中的 intervalAddede - 封裝事件資訊的 ListDataEventpublic void intervalRemoved(ListDataEvent e)
ListDataListener 中的 intervalRemovede - 封裝事件資訊的 ListDataEventpublic boolean selectWithKeyChar(char keyChar)
keyChar - 一個 char,它通常是使用者鍵入的鍵盤鍵public void setEnabled(boolean b)
JComponent 中的 setEnabledb - 一個 boolean 值,為 true 時,啟用該元件,為 false 時,禁用該元件Component.isEnabled(),
Component.isLightweight()
public void configureEditor(ComboBoxEditor anEditor,
Object anItem)
anEditor - 顯示組合框欄位中的列表項,並可以對其進行編輯的 ComboBoxEditoranItem - 要在欄位中顯示和編輯的物件public void processKeyEvent(KeyEvent e)
KeyEvent,尋找 Tab 鍵。如果找不到 Tab 鍵,則關閉彈出視窗。
JComponent 中的 processKeyEvente - 套件含按下的鍵盤鍵的 KeyEventKeyEvent,
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()
KeySelectionManagerpublic int getItemCount()
public Object getItemAt(int index)
index 超出範圍(小於零或者大於等於列表大小),則返回 null。
index - 指示列表位置的整數,其中第一項從零開始
Object;如果超出範圍,則返回 nullprotected JComboBox.KeySelectionManager createDefaultKeySelectionManager()
KeySelectionManagersetKeySelectionManager(javax.swing.JComboBox.KeySelectionManager)protected String paramString()
JComboBox 的字元串表示形式。此方法僅在進行除錯時使用,對於各個實作,所返回字元串的內容和格式可能有所不同。返回的字元串可以為空,但不可以為 null。
JComponent 中的 paramStringJComboBox 的字元串表示形式public AccessibleContext getAccessibleContext()
Accessible 中的 getAccessibleContextJComponent 中的 getAccessibleContext
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。