public class BasicComboBoxUI extends ComboBoxUI
コンボボックスは、複合コンポーネント、つまり多くの単純なコンポーネントの集合です。このクラスは、コンボボックスとコンボ・ボックス・モデル上のリスナーを作成し、管理します。これらのリスナーは、コンボボックスの状態とプロパティにおける変更に応じて、ユーザー・インタフェースを更新します。
すべてのイベント処理は、createxxxListener()の各メソッド、および内部クラスを使用して作成されたリスナー・クラスにより処理されます。このクラスの動作を変更するには、createxxxListener()の各メソッドをオーバーライドした上で、独自のイベント・リスナーを提供するか、このクラスで提供されているイベント・リスナーからサブクラス化します。
特定のアクションを追加するには、installKeyboardActionsをオーバーライドして、KeyStrokeバインディングに応じてアクションを追加します。記事「キー・バインディングの使用方法」を参照してください。
| 修飾子と型 | クラスと説明 |
|---|---|
class |
BasicComboBoxUI.ComboBoxLayoutManager
このレイアウト・マネージャは、コンボボックスの「標準」レイアウトを扱います。
|
class |
BasicComboBoxUI.FocusHandler
フォーカスが失われたときに、このリスナーはポップアップを隠します。
|
class |
BasicComboBoxUI.ItemHandler
このリスナーは、コンボボックスの選択の変更を監視します。
|
class |
BasicComboBoxUI.KeyHandler
このリスナーは、キー・イベントがナビゲーション・キーでないかどうかを確認します。
|
class |
BasicComboBoxUI.ListDataHandler
このリスナーは、
ComboBoxModel内での変更を監視します。 |
class |
BasicComboBoxUI.PropertyChangeHandler
このリスナーは、コンボボックス内で変更されたバウンド・プロパティを監視します。
|
| 修飾子と型 | フィールドと説明 |
|---|---|
protected JButton |
arrowButton |
protected Dimension |
cachedMinimumSize |
protected JComboBox |
comboBox |
protected CellRendererPane |
currentValuePane |
protected Component |
editor |
protected FocusListener |
focusListener
このprotectedフィールドは実装固有のものです。
|
protected boolean |
hasFocus
このprotectedフィールドは実装固有のものです。
|
protected boolean |
isMinimumSizeDirty |
protected ItemListener |
itemListener
このprotectedフィールドは実装固有のものです。
|
protected KeyListener |
keyListener
このprotectedフィールドは実装固有のものです。
|
protected JList |
listBox |
protected ListDataListener |
listDataListener
このprotectedフィールドは実装固有のものです。
|
protected Insets |
padding
これらのイン・セットは、「選択された」項目をコンボボックスに配置し、ペイントする際に、セル・レンダラ周囲のパディングとして機能します。
|
protected ComboPopup |
popup |
protected KeyListener |
popupKeyListener |
protected MouseListener |
popupMouseListener |
protected MouseMotionListener |
popupMouseMotionListener |
protected PropertyChangeListener |
propertyChangeListener
このprotectedフィールドは実装固有のものです。
|
protected boolean |
squareButton
コンボボックス・ボタンを正方形にするべきかどうかを示します。
|
| コンストラクタと説明 |
|---|
BasicComboBoxUI() |
| 修飾子と型 | メソッドと説明 |
|---|---|
void |
addEditor()
このpublicメソッドは実装固有のもので、privateであるべきです。
|
void |
configureArrowButton()
このpublicメソッドは実装固有のもので、privateであるべきです。
|
protected void |
configureEditor()
このprotectedメソッドは実装固有のもので、privateであるべきです。
|
protected JButton |
createArrowButton()
コンボボックスのポップアップ部分の表示または非表示の制御に使用されるボタンを作成します。
|
protected ComboBoxEditor |
createEditor()
編集可能なコンボボックスで使用されるデフォルト・エディタを作成します。
|
protected FocusListener |
createFocusListener()
コンボボックスに追加される
FocusListenerを作成します。 |
protected ItemListener |
createItemListener()
コンボボックスに追加される
ItemListenerを作成します。 |
protected KeyListener |
createKeyListener()
コンボボックスに追加される
KeyListenerを作成します。 |
protected LayoutManager |
createLayoutManager()
コンボボックスを構成するコンポーネントを管理するためのレイアウト・マネージャを作成します。
|
protected ListDataListener |
createListDataListener()
ComboBoxModelに追加されるリスト・データ・リスナーを作成します。 |
protected ComboPopup |
createPopup()
コンボボックスのポップアップ部分を作成します。
|
protected PropertyChangeListener |
createPropertyChangeListener()
コンボボックスに追加される
PropertyChangeListenerを作成します。 |
protected ListCellRenderer |
createRenderer()
編集不可能なコンボボックスで使用されるデフォルト・レンダラを作成します。
|
static ComponentUI |
createUI(JComponent c) |
Accessible |
getAccessibleChild(JComponent c, int i)
オブジェクトの
i番目のAccessibleの子を返します。 |
int |
getAccessibleChildrenCount(JComponent c)
オブジェクト内のアクセシビリティ対応の子の数を返します。
|
int |
getBaseline(JComponent c, int width, int height)
ベースラインを返します。
|
Component.BaselineResizeBehavior |
getBaselineResizeBehavior(JComponent c)
サイズの変化に合わせてコンポーネントのベースラインがどのように変化するかを示す列挙を返します。
|
protected Dimension |
getDefaultSize()
現在のレンダラとフォントを使用するコンボボックスの、空のディスプレイ領域のデフォルト・サイズを返します。
|
protected Dimension |
getDisplaySize()
ディスプレイ領域の、計算されたサイズを返します。
|
protected Insets |
getInsets()
JComboBoxからイン・セットを取得します。
|
Dimension |
getMaximumSize(JComponent c)
指定されたコンポーネントの、Look & Feelに適した最大サイズを返します。
|
Dimension |
getMinimumSize(JComponent c)
最小サイズは、ディスプレイ領域、インセットおよびボタンを足したサイズです。
|
Dimension |
getPreferredSize(JComponent c)
指定されたコンポーネントの、Look & Feelに適した推奨サイズを返します。
|
protected Dimension |
getSizeForComponent(Component comp)
セル・レンダラとして使用された場合のコンポーネントのサイズを返します。
|
protected void |
installComponents()
集合コンボボックスを構成するコンポーネントを作成し、初期化します。
|
protected void |
installDefaults()
JComboBoxに、デフォルトのカラー、フォント、レンダラ、およびエディタをインストールします。
|
protected void |
installKeyboardActions()
JComboBoxにキーボード・アクションを追加します。
|
protected void |
installListeners()
コンボボックスとそのモデルのためのリスナーを作成し、インストールします。
|
void |
installUI(JComponent c)
指定されたコンポーネントをLook & Feelに応じて適切に構成します。
|
boolean |
isFocusTraversable(JComboBox c)
JComboBoxが、フォーカスのトラバースが可能であるかどうかを判定します。
|
protected boolean |
isNavigationKey(int keyCode)
指定されたkeyCodeが、ナビゲーション用のキーにマップされるかどうかを返します。
|
boolean |
isPopupVisible(JComboBox c)
ポップアップが可視かどうかを判定します。
|
void |
paint(Graphics g, JComponent c)
指定されたコンポーネントをLook & Feelに合わせてペイントします。
|
void |
paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
現在選択されている項目をペイントします。
|
void |
paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus)
現在選択されている項目のバックグラウンドをペイントします。
|
protected Rectangle |
rectangleForCurrentValue()
現在選択されている項目を描画するために予約されている領域を返します。
|
void |
removeEditor()
このpublicメソッドは実装固有のもので、privateであるべきです。
|
protected void |
selectNextPossibleValue()
リストの次の項目を選択します。
|
protected void |
selectPreviousPossibleValue()
リストから1つ前の項目を選択します。
|
void |
setPopupVisible(JComboBox c, boolean v)
ポップアップを非表示にします。
|
protected void |
toggleOpenClose()
ポップアップが表示されている場合は非表示にし、非表示になっている場合は表示します。
|
void |
unconfigureArrowButton()
このpublicメソッドは実装固有のもので、privateであるべきです。
|
protected void |
unconfigureEditor()
このprotectedメソッドは実装固有のもので、privateであるべきです。
|
protected void |
uninstallComponents()
コンボ・ボックスを構成する集合コンポーネントは登録解除され、初期化解除されます。
|
protected void |
uninstallDefaults()
コンボボックスからデフォルトのカラー、フォント、レンダラ、およびエディタをアンインストールします。
|
protected void |
uninstallKeyboardActions()
フォーカスInputMapおよびActionMapを削除します。
|
protected void |
uninstallListeners()
インストールされたリスナーを、コンボボックスとそのモデルから削除します。
|
void |
uninstallUI(JComponent c)
installUI時に、指定されたコンポーネントに対して行われた構成を取り消します。 |
contains, updateprotected JComboBox comboBox
protected boolean hasFocus
protected JList listBox
protected CellRendererPane currentValuePane
protected ComboPopup popup
protected Component editor
protected JButton arrowButton
protected KeyListener keyListener
createKeyListener()protected FocusListener focusListener
createFocusListener()protected PropertyChangeListener propertyChangeListener
protected ItemListener itemListener
createItemListener()protected MouseListener popupMouseListener
protected MouseMotionListener popupMouseMotionListener
protected KeyListener popupKeyListener
protected ListDataListener listDataListener
createListDataListener()protected boolean isMinimumSizeDirty
protected Dimension cachedMinimumSize
protected boolean squareButton
protected Insets padding
public static ComponentUI createUI(JComponent c)
public void installUI(JComponent c)
ComponentUIComponentUIインスタンスが、指定されたコンポーネントのUI委譲としてインストールされているときに呼び出されます。このメソッドは、次を含むLook & Feel用のコンポーネントを完全に構成するべきです。
LayoutManagerをインストールする。
PropertyChangeListenerを作成してコンポーネントにインストールする。
installUI、クラス: ComponentUIc - UI委譲がインストールされるコンポーネントComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()public void uninstallUI(JComponent c)
ComponentUIinstallUI時に、指定されたコンポーネントに対して行われた構成を取り消します。このメソッドは、このUIComponentインスタンスが、指定されたコンポーネントのUI委譲として削除されているときに呼び出されます。このメソッドは、installUIによって実行された構成を元に戻すべきです。この場合、JComponentインスタンスをクリーンな状態(余分なリスナーや、Look & Feel固有のプロパティ・オブジェクトが残らないように)にするよう十分注意してください。手順には次のものが含まれるべきです。
uninstallUI、クラス: ComponentUIc - このUI委譲が削除されるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()protected void installDefaults()
protected void installListeners()
protected void uninstallDefaults()
protected void uninstallListeners()
installListenersで追加されたものと同じであるべきです。protected ComboPopup createPopup()
ComboPopupのインスタンスComboPopupprotected KeyListener createKeyListener()
KeyListenerを作成します。このメソッドがnullを返す場合、コンボボックスには追加されません。KeyListenerのインスタンスまたはnullprotected FocusListener createFocusListener()
FocusListenerを作成します。このメソッドがnullを返す場合、コンボボックスには追加されません。FocusListenerのインスタンス、またはnullprotected ListDataListener createListDataListener()
ComboBoxModelに追加されるリスト・データ・リスナーを作成します。このメソッドがnullを返す場合、コンボ・ボックス・モデルには追加されません。ListDataListenerのインスタンス、またはnullprotected ItemListener createItemListener()
ItemListenerを作成します。このメソッドがnullを返す場合、コンボボックスには追加されません。
サブクラスは、このメソッドをオーバーライドして、独自のItemEventハンドラのインスタンスを返すことができます。
ItemListenerのインスタンス、またはnullprotected PropertyChangeListener createPropertyChangeListener()
PropertyChangeListenerを作成します。このメソッドがnullを返す場合、コンボボックスには追加されません。PropertyChangeListenerのインスタンス、またはnullprotected LayoutManager createLayoutManager()
protected ListCellRenderer createRenderer()
setRendererで明示的に設定されていない場合だけ、デフォルト・レンダラが使用されます。ListCellRenderJComboBox.setRenderer(javax.swing.ListCellRenderer<? super E>)protected ComboBoxEditor createEditor()
setEditorで明示的に設定されていない場合だけ、デフォルト・エディタが使用されます。ComboBoxEditorJComboBox.setEditor(javax.swing.ComboBoxEditor)protected void installComponents()
protected void uninstallComponents()
public void addEditor()
ComboBoxEditorを作成してください。public void removeEditor()
addEditor()protected void configureEditor()
addEditor()protected void unconfigureEditor()
addEditor()public void configureArrowButton()
createArrowButton()public void unconfigureArrowButton()
createArrowButton()protected JButton createArrowButton()
public boolean isPopupVisible(JComboBox c)
isPopupVisible、クラス: ComboBoxUIpublic void setPopupVisible(JComboBox c, boolean v)
setPopupVisible、クラス: ComboBoxUIpublic boolean isFocusTraversable(JComboBox c)
isFocusTraversable、クラス: ComboBoxUIpublic void paint(Graphics g, JComponent c)
ComponentUIComponentUI.updateメソッドから呼び出されます。サブクラスは、このメソッドをオーバーライドして、指定されたGraphicsオブジェクトを使ってコンポーネントの内容を描画するべきです。paint、クラス: ComponentUIg - ペイント対象のGraphicsコンテキストc - ペイントされるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるComponentUI.update(java.awt.Graphics, javax.swing.JComponent)public Dimension getPreferredSize(JComponent c)
ComponentUInullが返された場合、適切なサイズは代わりにコンポーネントのレイアウト・マネージャによって計算されます(これは、特定のレイアウト・マネージャをインストールしてあるコンポーネントの場合に推奨する方法です)。このメソッドのデフォルト実装はnullを返します。getPreferredSize、クラス: ComponentUIc - 推奨サイズが照会されるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるJComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)public Dimension getMinimumSize(JComponent c)
getMinimumSize、クラス: ComponentUIc - 最小サイズが照会されるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるDimensionオブジェクトまたはnullJComponent.getMinimumSize(), LayoutManager.minimumLayoutSize(java.awt.Container), ComponentUI.getPreferredSize(javax.swing.JComponent)public Dimension getMaximumSize(JComponent c)
ComponentUInullが返された場合、最大サイズは代わりにコンポーネントのレイアウト・マネージャによって計算されます(これは、特定のレイアウト・マネージャをインストールしてあるコンポーネントの場合に推奨する方法です)。このメソッドのデフォルト実装はgetPreferredSizeを呼び出して、その値を返します。getMaximumSize、クラス: ComponentUIc - 最大サイズが照会されるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるDimensionオブジェクトまたはnullJComponent.getMaximumSize(), LayoutManager2.maximumLayoutSize(java.awt.Container)public int getBaseline(JComponent c, int width, int height)
getBaseline、クラス: ComponentUIc - ベースラインが要求されるJComponentwidth - ベースラインを取得する幅height - ベースラインを取得する高さNullPointerException - cがnullである場合IllegalArgumentException - 幅または高さが0より小さい場合JComponent.getBaseline(int, int)public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior、クラス: ComponentUIc - ベースラインのサイズ変更の動作を返すJComponentNullPointerException - cがnullである場合JComponent.getBaseline(int, int)public int getAccessibleChildrenCount(JComponent c)
ComponentUIAccessibleインタフェースを実装している場合、このメソッドはこのオブジェクトの子の数を返すべきです。UIが、画面上にコンポーネントとして表示される領域は提供するが、実際のコンポーネントがこの領域を提供するために使用されない場合、UIにおいて必要に応じてこのメソッドをオーバーライドできます。注: バージョン1.3以降は、このメソッドの代わりにComponent.AccessibleAWTComponent.getAccessibleChildrenCount()を呼び出すことをお勧めします。getAccessibleChildrenCount、クラス: ComponentUIComponentUI.getAccessibleChild(javax.swing.JComponent, int)public Accessible getAccessibleChild(JComponent c, int i)
ComponentUIi番目のAccessibleの子を返します。UIが、画面上にコンポーネントとして表示される領域は提供するが、この領域を提供するのに実際のコンポーネントを使用しない場合、UIは必要に応じてこのメソッドをオーバーライドします。
注: バージョン1.3以降は、このメソッドの代わりにComponent.AccessibleAWTComponent.getAccessibleChild()を呼び出すことをお勧めします。
getAccessibleChild、クラス: ComponentUIi - 子のゼロから始まるインデックスi番目のAccessibleの子ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent)protected boolean isNavigationKey(int keyCode)
protected void selectNextPossibleValue()
protected void selectPreviousPossibleValue()
protected void toggleOpenClose()
protected Rectangle rectangleForCurrentValue()
protected Insets getInsets()
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus)
protected Dimension getDefaultSize()
getDisplaySize()protected Dimension getDisplaySize()
項目数の多いコンボボックスについては、プロトタイプ・ディスプレイ値を使用して、ディスプレイ・サイズの計算を大幅に速めることをお勧めします。
JComboBox.setPrototypeDisplayValue(E)protected Dimension getSizeForComponent(Component comp)
comp - チェックするComponentprotected void installKeyboardActions()
protected void uninstallKeyboardActions()
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright© 1993, 2014, Oracle and/or its affiliates. All rights reserved.