|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JComboBox
Swing の ComboBox の実装です。ComboBox はテキストフィールドとコンボボックスの組み合わせであり、ユーザが値を入力するか、またはユーザが要求したときに表示されるリストから値を選択します。JComboBox がドロップダウンリストとしてだけ機能するように、編集機能を無効にすることもできます。
標準の Look & Feel (L&F) 表現でこのコンポーネントが使用するキーボードのキーについては、JComboBox のキーの割り当てを参照してください。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。今後の Swing リリースでは、長期間の持続性をサポートする予定です。
内部クラスの概要 | |
protected class |
JComboBox.AccessibleJComboBox
オブジェクトのユーザ補助機能を取得するために使用されるクラスです。 |
static interface |
JComboBox.KeySelectionManager
KeySelectionManager を定義するインタフェースです。 |
クラス javax.swing.JComponent から継承した内部クラス |
JComponent.AccessibleJComponent |
フィールドの概要 | |
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 |
コンストラクタの概要 | |
JComboBox()
デフォルトのデータモデルで JComboBox を作成します。 |
|
JComboBox(ComboBoxModel aModel)
既存の ComboBoxModel から項目を利用する JComboBox を作成します。 |
|
JComboBox(Object[] items)
指定された配列に要素を格納する JComboBox を作成します。 |
|
JComboBox(Vector items)
指定された Vector に要素を格納する JComboBox を作成します。 |
メソッドの概要 | |
void |
actionPerformed(ActionEvent e)
このメソッドは public になっていますが、これは実装の副作用によるものです。 |
void |
addActionListener(ActionListener l)
ActionListener を追加します。 |
void |
addItem(Object anObject)
項目リストに項目を追加します。 |
void |
addItemListener(ItemListener aListener)
ItemListener を追加します。 |
void |
configureEditor(ComboBoxEditor anEditor,
Object anItem)
指定された項目でエディタを初期化します。 |
void |
contentsChanged(ListDataEvent e)
このメソッドは public になっていますが、これは実装の副作用によるものです。 |
protected JComboBox.KeySelectionManager |
createDefaultKeySelectionManager()
デフォルトのキー選択マネージャのインスタンスを返します。 |
protected void |
fireActionEvent()
このイベントタイプへの通知を配信対象に登録しているリスナーをすべて通知します。 |
protected void |
fireItemStateChanged(ItemEvent e)
このイベントタイプへの通知を配信対象に登録しているリスナーをすべて通知します。 |
AccessibleContext |
getAccessibleContext()
JComponent に関連付けられている AccessibleContext を取得します。 |
String |
getActionCommand()
アクションリスナーに送られるイベントに含まれているアクションコマンドを返します。 |
ComboBoxEditor |
getEditor()
選択された項目を JComboBox フィールドで描画および編集するために使用するエディタを返します。 |
Object |
getItemAt(int index)
指定されたインデックスにあるリスト項目を返します。 |
int |
getItemCount()
リスト内の項目の数を返します。 |
JComboBox.KeySelectionManager |
getKeySelectionManager()
リストのキー選択マネージャを返します。 |
int |
getMaximumRowCount()
コンボボックスがスクロールバーを使用しないで表示できる最大の項目数を返します。 |
ComboBoxModel |
getModel()
JComboBox によって現在使用されているデータモデルを返します。 |
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 |
isFocusTraversable()
コンポーネントがフォーカスを受け取ることができる場合に true を返します。 |
boolean |
isLightWeightPopupEnabled()
軽量ポップアップ (すべて Java のポップアップ) が使用されている場合は true を返し、重量 (ネイティブピア) ポップアップが使用されている場合は false を返します。 |
boolean |
isPopupVisible()
ポップアップの可視性を判定します。 |
protected String |
paramString()
この JComboBox の文字列表現を返します。 |
void |
processKeyEvent(KeyEvent e)
Tab キーを探しながら、KeyEvent を処理します。 |
void |
removeActionListener(ActionListener l)
ActionListener を削除します。 |
void |
removeAllItems()
項目リストからすべての項目を削除します。 |
void |
removeItem(Object anObject)
項目リストから項目を削除します。 |
void |
removeItemAt(int anIndex)
anIndex にある項目を削除します。 |
void |
removeItemListener(ItemListener aListener)
ItemListener を削除します。 |
protected void |
selectedItemChanged()
選択されている項目が変更されるときに呼び出されます。 |
boolean |
selectWithKeyChar(char keyChar)
指定されたキーボードの文字に対応するリスト項目を選択し、その文字に対応する項目がある場合に true を返します。 |
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)
ポップアップを表示するとき、それが適当であれば JComboBox は軽量ポップアップの使用を選択します。 |
void |
setMaximumRowCount(int count)
JComboBox が表示する最大の行数を設定します。 |
void |
setModel(ComboBoxModel aModel)
JComboBox が項目のリストを取得するために使用するデータモデルを設定します。 |
void |
setPopupVisible(boolean v)
ポップアップの可視性を設定します。 |
void |
setRenderer(ListCellRenderer aRenderer)
JComboBox フィールドのリストから選択された項目を描画するレンダリングを設定します。 |
void |
setSelectedIndex(int anIndex)
インデックス anIndex にある項目を選択します。 |
void |
setSelectedItem(Object anObject)
リストでオブジェクトを指定することにより、JComboBox で選択されている項目を設定します。 |
void |
setUI(ComboBoxUI ui)
コンポーネントを描画する L&F オブジェクトを設定します。 |
void |
showPopup()
コンボボックスにポップアップウィンドウを表示させます。 |
void |
updateUI()
L&F が変更されたことを示す UIFactory からの通知です。 |
クラス java.lang.Object から継承したメソッド |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
フィールドの詳細 |
protected ComboBoxModel dataModel
protected ListCellRenderer renderer
protected ComboBoxEditor editor
protected int maximumRowCount
protected boolean isEditable
protected Object selectedItemReminder
protected JComboBox.KeySelectionManager keySelectionManager
protected String actionCommand
protected boolean lightWeightPopupEnabled
コンストラクタの詳細 |
public JComboBox(ComboBoxModel aModel)
aModel
- 表示された項目のリストを提供する ComboBoxModelpublic JComboBox(Object[] items)
public JComboBox(Vector items)
public JComboBox()
addItem
を使用すると、項目を追加できます。メソッドの詳細 |
protected void installAncestorListener()
public void setUI(ComboBoxUI ui)
ui
- ComboBoxUI L&F オブジェクトUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
JComponent.updateUI()
public String getUIClassID()
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public ComboBoxUI getUI()
public void setModel(ComboBoxModel aModel)
aModel
- 表示された項目のリストを提供する ComboBoxModelpublic ComboBoxModel getModel()
public void setLightWeightPopupEnabled(boolean aFlag)
public boolean isLightWeightPopupEnabled()
public void setEditable(boolean aFlag)
aFlag
- boolean 値。true はフィールドが編集可能であることを示すpublic boolean isEditable()
public void setMaximumRowCount(int count)
count
- スクロールバーを使用しないでリストに表示できる最大の項目数を指定する int 値public int getMaximumRowCount()
public void setRenderer(ListCellRenderer aRenderer)
デフォルトのレンダリングは、選択されたオブジェクトの toString
メソッドを呼び出して取得された文字列を表示します。ほかのレンダリングは、グラフィックイメージおよび複合項目を処理できます。
選択された項目を表示するには、リストオブジェクトおよびインデックス -1 を渡して aRenderer.getListCellRendererComponent
を呼び出します。
aRenderer
- 選択された項目を表示する ListCellRenderersetEditor(javax.swing.ComboBoxEditor)
public ListCellRenderer getRenderer()
public void setEditor(ComboBoxEditor anEditor)
anEditor
- 選択された項目を表示する ComboBoxEditorsetRenderer(javax.swing.ListCellRenderer)
public ComboBoxEditor getEditor()
public void setSelectedItem(Object anObject)
anObject
がリストにある場合、そのリストは anObject
が表示されている状態で表示されます。オブジェクトがリストにない場合、デフォルトのデータモデルはリストの最初の項目を選択します。anObject
- 選択するリストオブジェクトpublic Object getSelectedItem()
public void setSelectedIndex(int anIndex)
anIndex
にある項目を選択します。anIndex
- 選択するリスト項目を指定する int 値。0 はリスト内の最初の項目を指定するpublic int getSelectedIndex()
public void addItem(Object anObject)
anObject
- リストに追加する Objectpublic void insertItemAt(Object anObject, int index)
anObject
- リストに追加する Objectindex
- 項目を追加する位置を指定する int 値public void removeItem(Object anObject)
anObject
- 項目リストから削除するオブジェクトpublic void removeItemAt(int anIndex)
anIndex
にある項目を削除します。このメソッドは、JComboBox がデフォルトのデータモデルを使用する場合だけ機能します。JComboBox は、空のコンストラクタで作成されていて、ほかのモデルが設定されていない場合にデフォルトのデータモデルを使用します。anIndex
- 削除する項目のインデックスを指定する int 値。0 はリスト内の最初の項目を示す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)
aListener
は、選択されている項目が変更するときにイベントを受信します。aListener
- 通知される ItemListenerpublic void removeItemListener(ItemListener aListener)
aListener
- 削除する ItemListenerpublic void addActionListener(ActionListener l)
l
- 通知される ActionListenerpublic void removeActionListener(ActionListener l)
l
- 削除する ActionListenerpublic void setActionCommand(String aCommand)
aCommand
- アクションリスナーに送られる「コマンド」を含む文字列。リスナーは、受信するコマンドに応じて異なる処理を実行できるpublic String getActionCommand()
protected void fireItemStateChanged(ItemEvent e)
EventListenerList
protected void fireActionEvent()
EventListenerList
protected void selectedItemChanged()
public Object[] getSelectedObjects()
public void actionPerformed(ActionEvent e)
public void contentsChanged(ListDataEvent e)
ListDataListener
public boolean selectWithKeyChar(char keyChar)
keyChar
- char 値。通常は、ユーザが押したキーボードのキーpublic void intervalAdded(ListDataEvent e)
ListDataListener
public void intervalRemoved(ListDataEvent e)
ListDataListener
public void setEnabled(boolean b)
b
- boolean 値。コンポーネントを有効にする場合は true、無効にする場合は falsepublic void configureEditor(ComboBoxEditor anEditor, Object anItem)
anEditor
- コンボボックスのフィールドでリスト項目を表示し、その編集を可能にする ComboBoxEditoranItem
- フィールドで表示および編集を行うオブジェクトpublic void processKeyEvent(KeyEvent e)
e
- 押されたキーボードキーを含む KeyEventpublic boolean isFocusTraversable()
public void setKeySelectionManager(JComboBox.KeySelectionManager aManager)
public JComboBox.KeySelectionManager getKeySelectionManager()
public int getItemCount()
public Object getItemAt(int index)
index
- リスト位置を示す int 値。最初の項目は 0で始まるprotected JComboBox.KeySelectionManager createDefaultKeySelectionManager()
setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager)
protected String paramString()
null
にはなりません。
JFC コンポーネントの新しい側面についての情報を返すには、paramString() をオーバーライドします。
public AccessibleContext getAccessibleContext()
|
Java プラットフォーム 1.2 |
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | |||||||||
概要: 内部クラス | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |