JavaTM 2 Platform
Std. Ed. v1.3

javax.swing
クラス JComboBox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JComboBox
すべての実装インタフェース:
Accessible, ActionListener, EventListener, ImageObserver, ItemSelectable, ListDataListener, MenuContainer, Serializable

public class JComboBox
extends JComponent
implements ItemSelectable, ListDataListener, ActionListener, Accessible

ボタンまたはテキストフィールドと、ドロップダウンリストとを結び付けるコンポーネントです。ユーザは、要求に応じて表示されるドロップダウンリストから値を選択できます。コンボボックスを編集可能にすると、コンボボックスにはユーザが値を入力できるテキストフィールドが含まれます。コンボボックス使用の例と情報については、「The Java Tutorial」「How to Use Combo Boxes」を参照してください。

標準の Look & Feel (L&F) 表現でこのコンポーネントが使用するキーボードのキーについては、JComboBox のキーの割り当てを参照してください。

警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。今後の Swing リリースでは、長期間の持続性をサポートする予定です。

関連項目:
直列化された形式

内部クラスの概要
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
 
フィールドの概要
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)
          項目を既存の 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)
          指定された項目でエディタを初期化します。
protected  void configurePropertiesFromAction(Action a)
          Action インスタンスの値に従って ActionEvent ソースのプロパティを設定するファクトリメソッドです。
 void contentsChanged(ListDataEvent e)
          このメソッドは public になっていますが、これは実装の副作用によるものです。
protected  PropertyChangeListener createActionPropertyChangeListener(Action a)
          ActionEvent ソースを Action インスタンスのプロパティの変更に従って更新するのに使う PropertyChangeListener を生成するファクトリメソッドです。
protected  JComboBox.KeySelectionManager createDefaultKeySelectionManager()
          デフォルトのキー選択マネージャのインスタンスを返します。
protected  void fireActionEvent()
          このイベントタイプの通知を配信対象として登録しているリスナーすべてに通知します。
protected  void fireItemStateChanged(ItemEvent e)
          このイベントタイプの通知を配信対象として登録しているリスナーすべてに通知します。
 AccessibleContext getAccessibleContext()
          この JComboBox に関連した AccessibleContext を返します。
 Action getAction()
          この ActionEvent ソースに現在設定されている Action を返します。
 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 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)
          ポップアップを表示するとき、それが適当であれば 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 からの通知です。
 
クラス javax.swing.JComponent から継承したメソッド
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
クラス java.awt.Container から継承したメソッド
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
クラス java.awt.Component から継承したメソッド
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

dataModel

protected ComboBoxModel dataModel

renderer

protected ListCellRenderer renderer

editor

protected ComboBoxEditor editor

maximumRowCount

protected int maximumRowCount

isEditable

protected boolean isEditable

selectedItemReminder

protected Object selectedItemReminder

keySelectionManager

protected JComboBox.KeySelectionManager keySelectionManager

actionCommand

protected String actionCommand

lightWeightPopupEnabled

protected boolean lightWeightPopupEnabled
コンストラクタの詳細

JComboBox

public JComboBox(ComboBoxModel aModel)
項目を既存の ComboBoxModel から取る JComboBox を生成します。ComboBoxModel が提供されるため、このコンストラクタを使って生成されたコンボボックスは、デフォルトのコンボボックスモデルを生成せず、挿入、削除、および追加の各メソッドの動作方法に強い影響を与えます。
パラメータ:
aModel - 表示された項目のリストを提供する ComboBoxModel
関連項目:
DefaultComboBoxModel

JComboBox

public JComboBox(Object[] items)
指定された配列に要素を格納する JComboBox を生成します。デフォルトでは、配列の最初の項目と、それにともなってデータモデルが選択されます。
パラメータ:
items - コンボボックスに挿入するオブジェクトの配列
関連項目:
DefaultComboBoxModel

JComboBox

public JComboBox(Vector items)
指定された Vector に要素を格納する JComboBox を生成します。デフォルトでは、ベクタの最初の項目と、それにともなってデータモデルが選択されます。
パラメータ:
items - コンボボックスに挿入するベクタの配列
関連項目:
DefaultComboBoxModel

JComboBox

public JComboBox()
デフォルトのデータモデルで JComboBox を生成します。デフォルトのデータモデルは、オブジェクトの空リストです。addItem を使って項目を追加します。デフォルトでは、データモデルの最初の項目が選択されます。
関連項目:
DefaultComboBoxModel
メソッドの詳細

installAncestorListener

protected void installAncestorListener()

setUI

public void setUI(ComboBoxUI ui)
このコンポーネントを描画する L&F オブジェクトを設定します。
パラメータ:
ui - ComboBoxUI L&F オブジェクト
関連項目:
UIDefaults.getUI(javax.swing.JComponent)

updateUI

public void updateUI()
L&F が変更されたことを示す UIFactory からの通知です。
オーバーライド:
クラス JComponent 内の updateUI
関連項目:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
このコンポーネントを描画する L&F クラスの名前を返します。
オーバーライド:
クラス JComponent 内の getUIClassID
戻り値:
文字列「ComboBoxUI」
関連項目:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

getUI

public ComboBoxUI getUI()
このコンポーネントを描画する L&F オブジェクトを返します。
戻り値:
このコンポーネントを描画する ComboBoxUI オブジェクト

setModel

public void setModel(ComboBoxModel aModel)
JComboBox が項目のリストを取得するために使用するデータモデルを設定します。
パラメータ:
aModel - 表示された項目のリストを提供する ComboBoxModel

getModel

public ComboBoxModel getModel()
JComboBox によって現在使用されているデータモデルを返します。
戻り値:
表示された項目のリストを提供する ComboBoxModel

setLightWeightPopupEnabled

public void setLightWeightPopupEnabled(boolean aFlag)
ポップアップを表示するとき、それが適当であれば JComboBox は軽量ポップアップの使用を選択します。このメソッドでは、この機能を無効にできます。アプリケーションが軽量コンポーネントと重量コンポーネントを混合する場合は、この機能を無効にしなければなりません。

isLightWeightPopupEnabled

public boolean isLightWeightPopupEnabled()
軽量 (すべて Java の) ポップアップを使用している場合は true を返し、重量 (ネイティブピアの) ポップアップを使用している場合は false を返します。
戻り値:
軽量ポップアップを使用している場合は true

setEditable

public void setEditable(boolean aFlag)
JComboBox フィールドが編集可能かどうかを指定します。編集可能な JComboBox では、ユーザはフィールドに入力するか、またはフィールドを初期化するためにリストから項目を選択でき、そのあとにその項目を編集できます (編集はフィールドだけに影響し、リスト項目には影響しない)。編集が不可能な JComboBox は選択された項目をフィールドに表示しますが、その選択は編集できません。
パラメータ:
aFlag - boolean 値。true はフィールドが編集可能であることを示す

isEditable

public boolean isEditable()
JComboBox が編集可能な場合は true を返します。デフォルトでは、コンボボックスは編集不可です。
戻り値:
JComboBox が編集可能な場合は true、そうでない場合は false

setMaximumRowCount

public void setMaximumRowCount(int count)
JComboBox が表示する最大の行数を設定します。モデル内のオブジェクト数が count より大きい場合は、コンボボックスはスクロールバーを使用します。
パラメータ:
count - スクロールバーを使用しないでリストに表示できる最大の項目数を指定する int 値

getMaximumRowCount

public int getMaximumRowCount()
コンボボックスがスクロールバーを使用しないで表示できる最大の項目数を返します。
戻り値:
スクロールバーを使用しないでリストに表示される最大の項目数を指定する int 値

setRenderer

public void setRenderer(ListCellRenderer aRenderer)
JComboBox フィールドのリストから選択された項目を描画するレンダリングを設定します。レンダリングは、JComboBox が編集不可能な場合に使用されます。編集可能な場合は、エディタを使用して選択された項目の描画および編集に、エディタが使用されます。

デフォルトのレンダリングは、選択されたオブジェクトの toString メソッドを呼び出して取得された文字列を表示します。ほかのレンダリングは、グラフィックイメージおよび複合項目を処理できます。

選択された項目を表示するには、リストオブジェクトおよびインデックス -1 を渡して aRenderer.getListCellRendererComponent を呼び出します。

パラメータ:
aRenderer - 選択された項目を表示する ListCellRenderer
関連項目:
setEditor(javax.swing.ComboBoxEditor)

getRenderer

public ListCellRenderer getRenderer()
選択された項目を JComboBox フィールドで表示するのに使われるレンダリングを返します。
戻り値:
選択された項目を表示する ListCellRenderer

setEditor

public void setEditor(ComboBoxEditor anEditor)
選択された項目を JComboBox フィールドで描画および編集するために使用されるエディタを設定します。エディタは、受け取る JComboBox が編集可能な場合だけ使用されます。編集できない場合は、コンボボックスはレンダリングを使用して選択された項目を描画します。
パラメータ:
anEditor - 選択された項目を表示する ComboBoxEditor
関連項目:
setRenderer(javax.swing.ListCellRenderer)

getEditor

public ComboBoxEditor getEditor()
選択された項目を JComboBox フィールドで描画および編集するために使用するエディタを返します。
戻り値:
選択された項目を表示する ComboBoxEditor

setSelectedItem

public void setSelectedItem(Object anObject)
リストのオブジェクトを指定して、選択された項目を JComboBox に設定します。anObject がリストにある場合、リストは選択された anObject を表示します。
パラメータ:
anObject - 選択するリストオブジェクト

getSelectedItem

public Object getSelectedItem()
現在選択されている項目を返します。
戻り値:
データモデルからの現在選択されているリストオブジェクト

setSelectedIndex

public void setSelectedIndex(int anIndex)
インデックス anIndex にある項目を選択します。
パラメータ:
anIndex - 選択するリスト項目を指定する int 値。0 はリスト内の最初の項目を指定する
例外:
IllegalArgumentException - anIndex が -1 より小さい場合、あるいは anIndex がサイズに等しいかそれより大きい場合

getSelectedIndex

public int getSelectedIndex()
指定された項目に一致する、リスト内の最初の項目を返します。JComboBox がリストにない項目の選択を許可する場合、その結果が常に定義されるとは限りません。項目が選択されていない場合、またはユーザがリストにない項目を指定した場合は、-1 が返されます。
戻り値:
現在選択されているリスト項目を指定する int 値。0 はリスト内の最初の項目を指定する。項目が選択されていない場合、または現在選択されている項目がリストにない場合は -1

addItem

public void addItem(Object anObject)
項目リストに項目を追加します。このメソッドは、JComboBox がデフォルトのデータモデルを使用する場合だけ機能します。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

insertItemAt

public void insertItemAt(Object anObject,
                         int index)
指定されたインデックスで項目リストに項目を挿入します。このメソッドは、JComboBox がデフォルトのデータモデルを使用する場合だけ機能します。JComboBox は、空のコンストラクタで生成されていて、ほかのモデルが設定されていない場合にデフォルトのデータモデルを使用します。
パラメータ:
anObject - リストに追加する Object
index - 項目を追加する位置を指定する int 値

removeItem

public void removeItem(Object anObject)
項目リストから項目を削除します。このメソッドは、JComboBox がデフォルトのデータモデルを使用する場合だけ機能します。JComboBox は、空のコンストラクタで生成されていて、ほかのモデルが設定されていない場合にデフォルトのデータモデルを使用します。
パラメータ:
anObject - 項目リストから削除するオブジェクト

removeItemAt

public void removeItemAt(int anIndex)
anIndex にある項目を削除します。このメソッドは、JComboBox がデフォルトのデータモデルを使用する場合だけ機能します。JComboBox は、空のコンストラクタで生成されていて、ほかのモデルが設定されていない場合にデフォルトのデータモデルを使用します。
パラメータ:
anIndex - 削除する項目のインデックスを指定する int 値。0 はリスト内の最初の項目を示す

removeAllItems

public void removeAllItems()
項目リストからすべての項目を削除します。

showPopup

public void showPopup()
コンボボックスにポップアップウィンドウを表示させます。
関連項目:
setPopupVisible(boolean)

hidePopup

public void hidePopup()
コンボボックスにポップアップウィンドウを閉じさせます。
関連項目:
setPopupVisible(boolean)

setPopupVisible

public void setPopupVisible(boolean v)
ポップアップの可視性を設定します。

isPopupVisible

public boolean isPopupVisible()
ポップアップの可視性を判定します。

addItemListener

public void addItemListener(ItemListener aListener)
ItemListener を追加します。aListener は、選択されている項目が変更されるときにイベントを受信します。
定義:
インタフェース ItemSelectable 内の addItemListener
パラメータ:
aListener - 通知される ItemListener

removeItemListener

public void removeItemListener(ItemListener aListener)
ItemListener を削除します。
定義:
インタフェース ItemSelectable 内の removeItemListener
パラメータ:
aListener - 削除される ItemListener

addActionListener

public void addActionListener(ActionListener l)
ActionListener を追加します。リスナーは、ユーザが選択を終了するアクションイベントを受信します。
パラメータ:
l - 通知される ActionListener

removeActionListener

public void removeActionListener(ActionListener l)
ActionListener を削除します。
パラメータ:
l - 削除される ActionListener

setActionCommand

public void setActionCommand(String aCommand)
アクションリスナーに送られるイベントに含まれなければならないアクションコマンドを設定します。
パラメータ:
aCommand - アクションリスナーに送られる「コマンド」を含む文字列。リスナーは、受信するコマンドに応じて異なる処理を実行できる

getActionCommand

public String getActionCommand()
アクションリスナーに送られるイベントに含まれているアクションコマンドを返します。
戻り値:
アクションリスナーに送られる「コマンド」を含む文字列

setAction

public void setAction(Action a)
ActionEvent ソースに Action を設定します。新しい Action は設定済みの Action と置き換わりますが、addActionListener で独立して追加された ActionListener には影響しません。Action がすでに ActionEvent ソースにすでに登録されている ActionListener である場合は、再登録されません。

Action を設定すると、ActionEvent ソースのプロパティが、Action の値から直ちに設定され (configurePropertiesFromAction メソッドで実行)、続いて createActionPropertyChangeListener メソッドが作成した PropertyChangeListener により、Action のプロパティの変更に従って更新されます。

パラメータ:
a - JComboBoxAction、または null
導入されたバージョン:
1.3
関連項目:
Action, getAction(), configurePropertiesFromAction(javax.swing.Action), createActionPropertyChangeListener(javax.swing.Action)

getAction

public Action getAction()
この ActionEvent ソースに現在設定されている Action を返します。Action が設定されていない場合は、null が返されます。
戻り値:
この ActionEvent ソースの Action、または null
導入されたバージョン:
1.3
関連項目:
Action, setAction(javax.swing.Action)

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action a)
Action インスタンスの値に従って ActionEvent ソースのプロパティを設定するファクトリメソッドです。設定されるプロパティはサブクラスによって異なります。デフォルトでは、設定されるプロパティは Enabled および ToolTipText です。
パラメータ:
a - プロパティを取得する Action、または null
導入されたバージョン:
1.3
関連項目:
Action, setAction(javax.swing.Action)

createActionPropertyChangeListener

protected PropertyChangeListener createActionPropertyChangeListener(Action a)
ActionEvent ソースを Action インスタンスのプロパティの変更に従って更新するのに使う PropertyChangeListener を生成するファクトリメソッドです。最新の状態で保持する必要のあるプロパティのセットがデフォルトプロパティ (Text、Icon、Enabled、ToolTipText) と異なる場合は、独自の PropertyChangeListener を提供するためにサブクラスがこのメソッドをオーバーライドすることがあります。 PropertyChangeListenerActionEvent ソースへの強参照を保持しないようにする必要があります。これは、ActionEvent ソースのガベージコレクションおよびすべての包含関係の階層のコンポーネントを妨害する可能性があるからです。
導入されたバージョン:
1.3
関連項目:
Action, setAction(javax.swing.Action)

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
このイベントタイプの通知を配信対象として登録しているリスナーすべてに通知します。
パラメータ:
e - 対象のイベント
関連項目:
EventListenerList

fireActionEvent

protected void fireActionEvent()
このイベントタイプの通知を配信対象として登録しているリスナーすべてに通知します。
パラメータ:
e - 対象のイベント
関連項目:
EventListenerList

selectedItemChanged

protected void selectedItemChanged()
選択されている項目が変更されるときに呼び出されます。デフォルトの実装は、項目リスナーに通知します。

getSelectedObjects

public Object[] getSelectedObjects()
選択されている項目を含む配列を返します。このメソッドは、ItemSelectable との互換性のために実装されます。
定義:
インタフェース ItemSelectable 内の getSelectedObjects
戻り値:
1 つの要素 (選択されている項目) を含む Object の配列

actionPerformed

public void actionPerformed(ActionEvent e)
このメソッドは public になっていますが、これは実装の副作用によるものです。呼び出したり、オーバーライドしたりしないでください。
定義:
インタフェース ActionListener 内の actionPerformed

contentsChanged

public void contentsChanged(ListDataEvent e)
このメソッドは public になっていますが、これは実装の副作用によるものです。呼び出したり、オーバーライドしたりしないでください。
定義:
インタフェース ListDataListener 内の contentsChanged
関連項目:
ListDataListener

selectWithKeyChar

public boolean selectWithKeyChar(char keyChar)
指定されたキーボードの文字に対応するリスト項目を選択し、その文字に対応する項目がある場合に true を返します。そうでない場合は false が返されます。
パラメータ:
keyChar - char 値。通常は、ユーザが押したキーボードのキー

intervalAdded

public void intervalAdded(ListDataEvent e)
項目が内部データモデルに追加されている場合に呼び出されます。「区間」には、追加された最初と最後の値が含まれます。
定義:
インタフェース ListDataListener 内の intervalAdded
関連項目:
ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
値がデータモデルから削除されている場合に呼び出されます。「区間」には、削除された最初と最後の値が含まれます。
定義:
インタフェース ListDataListener 内の intervalRemoved
関連項目:
ListDataListener

setEnabled

public void setEnabled(boolean b)
項目を選択できるようにコンボボックスを有効にします。コンボボックスが無効の場合、項目を選択できず、値をフィールドに入力できません (編集可能な場合)。
オーバーライド:
クラス JComponent 内の setEnabled
パラメータ:
b - boolean 値。true の場合はコンポーネントは有効になり、false の場合は無効になる

configureEditor

public void configureEditor(ComboBoxEditor anEditor,
                            Object anItem)
指定された項目でエディタを初期化します。
パラメータ:
anEditor - コンボボックスのフィールドにリスト項目を表示し、その編集を可能にする ComboBoxEditor
anItem - フィールドで表示および編集を行うオブジェクト

processKeyEvent

public void processKeyEvent(KeyEvent e)
Tab キーを探しながら、KeyEvent を処理します。Tab キーが見つかると、ポップアップウィンドウが閉じます。
オーバーライド:
クラス JComponent 内の processKeyEvent
パラメータ:
e - 押されたキーボードのキーを含む KeyEvent

isFocusTraversable

public boolean isFocusTraversable()
コンポーネントがフォーカスを受け取ることができる場合に true を返します。この場合、コンポーネントはそれが編集可能な場合に false を返し、その結果、Editor オブジェクトがコンポーネントの代わりにフォーカスを受け取ります。
オーバーライド:
クラス JComponent 内の isFocusTraversable
戻り値:
コンポーネントがフォーカスを受け取ることができる場合は true、そうでない場合は false

setKeySelectionManager

public void setKeySelectionManager(JComboBox.KeySelectionManager aManager)
キーボードの文字をリストの選択に変換するオブジェクトを設定します。通常、最初の文字が一致するものの内で最初に選択されたものが選択された項目になります。

getKeySelectionManager

public JComboBox.KeySelectionManager getKeySelectionManager()
リストのキー選択マネージャを返します。
戻り値:
現在使用されている KeySelectionManager

getItemCount

public int getItemCount()
リスト内の項目の数を返します。
戻り値:
リスト内の項目数に等しい int 値

getItemAt

public Object getItemAt(int index)
指定されたインデックスのリスト項目を返します。index が範囲外の場合、つまりゼロよりも小さいか、サイズ以上の場合は、null を返します。
パラメータ:
index - リスト位置を示す int 値。最初の項目は 0 で始まる
戻り値:
そのリスト位置の Object。範囲外の場合は null

createDefaultKeySelectionManager

protected JComboBox.KeySelectionManager createDefaultKeySelectionManager()
デフォルトのキー選択マネージャのインスタンスを返します。
戻り値:
リストが現在使用している KeySelectionManager
関連項目:
setKeySelectionManager(javax.swing.JComboBox.KeySelectionManager)

paramString

protected String paramString()
この JComboBox の文字列表現を返します。このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なります。返される文字列は空の場合がありますが、null にはなりません。
オーバーライド:
クラス JComponent 内の paramString
戻り値:
この JComboBox の文字列表現

getAccessibleContext

public AccessibleContext getAccessibleContext()
この JComboBox に関連した AccessibleContext を返します。コンボボックスの場合、AccessibleContext は AccessibleJComboBox の形式を取ります。必要に応じて新規の AccessibleJComboBox インスタンスが作成されます。
定義:
インタフェース Accessible 内の getAccessibleContext
オーバーライド:
クラス JComponent 内の getAccessibleContext
戻り値:
この JComboBox の AccessibleContext として機能する AccessibleJComboBox

JavaTM 2 Platform
Std. Ed. v1.3

バグや機能要求の報告
さらに詳しい API リファレンスおよび開発者ドキュメントについては、 Java 2 SDK SE Developer Documentation を参照してください。このドキュメントには、概念、用語の定義、回避策、 実用的なコード例など、開発者を対象にした詳細な解説が掲載されています。

Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.