java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ListUI
javax.swing.plaf.basic.BasicListUI
- 直系の既知のサブクラス:
- SynthListUI
public class BasicListUI extends ListUI
ListUIの拡張実装です。
 
 BasicListUIインスタンスは複数のリスト間で共有できません。
- 
ネストされたクラスのサマリーネストされたクラス 修飾子と型 クラス 説明 classBasicListUI.FocusHandlerこのクラスは、「protected」内部クラスとして扱うようにしてください。classBasicListUI.ListDataHandlerinstallUI timeのJListsモデルに追加されるListDataListener、およびJList.modelプロパティが変更されるたびに追加されます。classBasicListUI.ListSelectionHandlerinstallUI時およびJList.selectionModelプロパティ変更時にJLists選択モデルに追加されるListSelectionListenerです。classBasicListUI.MouseInputHandlerJListのためのマウス入力およびフォーカス処理です。classBasicListUI.PropertyChangeHandlerinstallUI時にJListに追加されるPropertyChangeListenerです。
- 
フィールドのサマリーフィールド 修飾子と型 フィールド 説明 protected intcellHeightセルの高さ。protected int[]cellHeightsセルの高さの配列protected static intcellRendererChangedこのビットは、セル・レンダラの変更されたプロパティに関連しています。protected intcellWidthセルの幅。protected static intfixedCellHeightChangedビットは固定セルの高さ変更プロパティに関連しています。protected static intfixedCellWidthChangedこのビットは、固定セル幅変更されたプロパティに関係します。protected FocusListenerfocusListenerJListに添付されたFocusListener。protected static intfontChangedこのビットは、フォントが変更されたプロパティに関連しています。protected JList<Object>listJListのインスタンス。protected ListDataListenerlistDataListenerJListに添付されたListDataListener。protected ListSelectionListenerlistSelectionListenerJListに添付されたListSelectionListener。protected static intmodelChangedこのビットは、モデル変更されたプロパティに関連しています。protected MouseInputListenermouseInputListenerJListに添付されたMouseInputListener。protected PropertyChangeListenerpropertyChangeListenerJListに添付されたPropertyChangeListener。protected static intprototypeCellValueChangedこのビットはプロト型のセル値が変更されたプロパティに関連しています。protected CellRendererPanerendererPaneCellRendererPaneのインスタンス。protected static intselectionModelChangedこのビットは、選択モデルの変更されたプロパティに関連しています。protected intupdateLayoutStateNeededこの値は、JListモデルの変更を表します。
- 
コンストラクタのサマリーコンストラクタ コンストラクタ 説明 BasicListUI()
- 
メソッドのサマリー修飾子と型 メソッド 説明 protected intconvertRowToY(int row)JList指定された行の原点の相対的なY座標を返します。もし行が有効でない場合は -1を返します。protected intconvertYToRow(int y0)現在のレイアウトに基づいて、JList相対座標をその座標を含む行に変換します。protected FocusListenercreateFocusListener()FocusListenerのインスタンスを返します。protected ListDataListenercreateListDataListener()必要に応じてJListsにモデル別に追加されるListDataListenerのインスタンスを作成します。protected ListSelectionListenercreateListSelectionListener()必要に応じてselectionModelによってJListsに追加されるListSelectionHandlerのインスタンスを作成します。protected MouseInputListenercreateMouseInputListener()MouseInputListenerを実装するデリゲートを作成します。protected PropertyChangeListenercreatePropertyChangeListener()installUI()によってJListに追加されるPropertyChangeHandlerのインスタンスを作成します。static ComponentUIcreateUI(JComponent list)BasicListUIの新しいインスタンスを返します。intgetBaseline(JComponent c, int width, int height)ベースラインを返します。Component.BaselineResizeBehaviorgetBaselineResizeBehavior(JComponent c)サイズの変化に合わせてコンポーネントのベースラインがどのように変化するかを示す列挙を返します。DimensiongetPreferredSize(JComponent c)リストのpreferredSizeはレイアウト方向によって決まります。protected intgetRowHeight(int row)現在のレイアウトに基づいて、指定された行の高さを返します。protected voidinstallDefaults()リストのプロパティ(フォント、フォアグラウンド、およびバックグラウンドなど)を初期化して、CellRendererPaneを追加します。protected voidinstallKeyboardActions()BasicListUIが関連付けられているJList上のキーボード・バインディングを登録します。protected voidinstallListeners()JList、そのモデル、およびそのselectionModelのリスナーを作成およびインストールします。voidinstallUI(JComponent c)installDefaults()、installListeners()、およびinstallKeyboardActions()を順番に呼び出して、this.listを初期化します。intlocationToIndex(JList<?> list, Point location)リストの座標系内の特定の位置にもっとも近い、指定されたJList内のセル・インデックスを返します。protected voidmaybeUpdateLayoutState()updateLayoutStateNeededがゼロでなければ、updateLayoutState()を呼び出してupdateLayoutStateNeededをリセットします。voidpaint(Graphics g, JComponent c)GraphicsオブジェクトclipRectと交差する行をペイントします。protected voidpaintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex)リスト・セルをペイント: 関連する状態をコンピュートし、"ラバー・スタンプ"セル・レンダラ・コンポーネントを取得し、CellRendererPaneを使用してペイントします。protected voidselectNextIndex()前の行を選択して、それを強制的に可視にします。protected voidselectPreviousIndex()前の行を選択して、それを強制的に可視にします。protected voiduninstallDefaults()明示的にオーバーライドされていないリスト・プロパティをnullに設定します。protected voiduninstallKeyboardActions()installKeyboardActionsからインストールされたキーボード・アクションの登録を解除します。protected voiduninstallListeners()JList、そのモデル、およびそのselectionModelからリスナーを削除します。voiduninstallUI(JComponent c)uninstallListeners()、uninstallKeyboardActions()、およびuninstallDefaults()を順番に呼び出して、this.listの初期化を解除します。protected voidupdateLayoutState()cellHeight (またはcellHeights)およびcellWidthの値を、現在のフォントと、fixedCellWidth、fixedCellHeight、およびprototypeCellValueの現在の値を基にして計算し直します。クラス javax.swing.plaf.ComponentUIで宣言されたメソッドcontains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
- 
フィールド詳細- 
listJListのインスタンス。
- 
rendererPaneprotected CellRendererPane rendererPaneCellRendererPaneのインスタンス。
- 
focusListenerprotected FocusListener focusListenerJListに添付されたFocusListener。
- 
mouseInputListenerprotected MouseInputListener mouseInputListenerJListに添付されたMouseInputListener。
- 
listSelectionListenerprotected ListSelectionListener listSelectionListenerJListに添付されたListSelectionListener。
- 
listDataListenerprotected ListDataListener listDataListenerJListに添付されたListDataListener。
- 
propertyChangeListenerprotected PropertyChangeListener propertyChangeListenerJListに添付されたPropertyChangeListener。
- 
cellHeightsprotected int[] cellHeightsセルの高さの配列
- 
cellHeightprotected int cellHeightセルの高さ。
- 
cellWidthprotected int cellWidthセルの幅。
- 
updateLayoutStateNeededprotected int updateLayoutStateNeededこの値は、JListモデルの変更を表します。
- 
modelChangedprotected static final int modelChangedこのビットは、モデル変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
 
- 
selectionModelChangedprotected static final int selectionModelChangedこのビットは、選択モデルの変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
 
- 
fontChangedprotected static final int fontChangedこのビットは、フォントが変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
 
- 
fixedCellWidthChangedprotected static final int fixedCellWidthChangedこのビットは、固定セル幅変更されたプロパティに関係します。- 関連項目:
- 定数フィールド値
 
- 
fixedCellHeightChangedprotected static final int fixedCellHeightChangedビットは固定セルの高さ変更プロパティに関連しています。- 関連項目:
- 定数フィールド値
 
- 
prototypeCellValueChangedprotected static final int prototypeCellValueChangedこのビットはプロト型のセル値が変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
 
- 
cellRendererChangedprotected static final int cellRendererChangedこのビットは、セル・レンダラの変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
 
 
- 
- 
コンストラクタの詳細- 
BasicListUIpublic BasicListUI()
 
- 
- 
メソッドの詳細- 
paintCellprotected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex)リスト・セルをペイント: 関連する状態をコンピュートし、"ラバー・スタンプ"セル・レンダラ・コンポーネントを取得し、CellRendererPaneを使用してペイントします。 サブクラスは、paint()ではなくこのメソッドをオーバーライドしたい場合があります。- パラメータ:
- g-- Graphicsのインスタンス
- row- 行
- rowBounds- レンダリングする境界矩形
- cellRenderer-- ListCellRendererのリスト
- dataModel- リスト・モデル
- selModel- 選択モデル
- leadIndex- リード指数
- 関連項目:
- paint(java.awt.Graphics, javax.swing.JComponent)
 
- 
paintpublic void paint(Graphics g, JComponent c)GraphicsオブジェクトclipRectと交差する行をペイントします。 このメソッドは、必要に応じてpaintCellを呼び出します。 サブクラスは、これらのメソッドをオーバーライドできます。- オーバーライド:
- paint、クラス:- ComponentUI
- パラメータ:
- g- ペイント対象の- Graphicsコンテキスト
- c- ペイントされるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがある
- 関連項目:
- paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer<java.lang.Object>, javax.swing.ListModel<java.lang.Object>, javax.swing.ListSelectionModel, int)
 
- 
getBaselinepublic int getBaseline(JComponent c, int width, int height)ベースラインを返します。- オーバーライド:
- getBaseline、クラス:- ComponentUI
- パラメータ:
- c- ベースラインが要求される- JComponent
- width- ベースラインを取得する幅
- height- ベースラインを取得する高さ
- 戻り値:
- ベースラインまたは0より小さい値(適切なベースラインがないことを示す)
- 例外:
- NullPointerException-- cが- nullである場合
- IllegalArgumentException- 幅または高さが0より小さい場合
- 導入されたバージョン:
- 1.6
- 関連項目:
- JComponent.getBaseline(int, int)
 
- 
getBaselineResizeBehaviorpublic Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)サイズの変化に合わせてコンポーネントのベースラインがどのように変化するかを示す列挙を返します。- オーバーライド:
- getBaselineResizeBehavior、クラス:- ComponentUI
- パラメータ:
- c- ベースラインのサイズ変更の動作を返す- JComponent
- 戻り値:
- コンポーネント・サイズの変化に合わせてベースラインがどのように変化するかを示す列挙
- 例外:
- NullPointerException-- cが- nullである場合
- 導入されたバージョン:
- 1.6
- 関連項目:
- JComponent.getBaseline(int, int)
 
- 
getPreferredSizepublic Dimension getPreferredSize(JComponent c)リストのpreferredSizeはレイアウト方向によって決まります。
 上記は、生の推奨される幅と高さです。 結果の推奨される幅は、上記の幅+insets.left+insets.right、結果の推奨される高さは、上記の高さ+insets.top+insets.bottomです。配置方向ごとに推奨サイズを記述します。 配置方向 推奨サイズ JList.VERTICAL リストのpreferredSizeは、行の高さの合計と、セルの最大幅です。 JList.fixedCellHeightが指定されている場合、行の高さの合計は(cellVerticalMargins+fixedCellHeight)* model.getSize()になります。rowVerticalMarginsは、黄色いフォーカス・アウトラインを描画するために割り当てる領域です。 同様に、fixedCellWidthが指定されている場合は、それを使用します。 JList.VERTICAL_WRAP 可視の行数が0より大きい場合、preferredHeightは、セルの最大の高さ* visibleRowCountになります。 可視の行数が0以下の場合、推奨される高さは、現在のリストの高さと、セルの最大の高さのうちの高いほうになります。 推奨される幅は、セルの最大幅*必要な列数、になります。 ここで、必要な列数はリストの高さ/セルの最大の高さです。 セルの最大の高さは、セルの固定の高さか、またはすべてのセルを反復してListCellRendererから最大の高さを見つけることによって決まります。 JList.HORIZONTAL_WRAP 可視の行数が0より大きい場合、preferredHeightは、セルの最大の高さ* adjustedRowCountになります。 visibleRowCountは、列数を決めるために使用されます。 水平に配置するため、行数は列数から決まります。 たとえば、10項目のモデルで可視行数が8だとします。 表示に必要な列は2列ですが、8行も必要なく、5行で済みます。したがって、adjustedRowCountは5になります。 可視行数が0以下の場合、推奨される高さは列数によって決まります。 JListの幅(幅/最大セル幅)に収まる数になります(1列以上)。 推奨される高さは、モデル・サイズ/列数*セルの最大の高さになります。 セルの最大の高さは、セルの固定の高さか、またはすべてのセルを反復してListCellRendererから最大の高さを見つけることによって決まります。Insetsはlist.getInsets()から決まります。- オーバーライド:
- getPreferredSize、クラス:- ComponentUI
- パラメータ:
- c- JListコンポーネント。
- 戻り値:
- リストの総サイズ。
- 関連項目:
- JComponent.getPreferredSize(),- LayoutManager.preferredLayoutSize(java.awt.Container)
 
- 
selectPreviousIndexprotected void selectPreviousIndex()前の行を選択して、それを強制的に可視にします。
- 
selectNextIndexprotected void selectNextIndex()前の行を選択して、それを強制的に可視にします。
- 
installKeyboardActionsprotected void installKeyboardActions()BasicListUIが関連付けられているJList上のキーボード・バインディングを登録します。 このメソッドは、installUI()時に呼び出されます。
- 
uninstallKeyboardActionsprotected void uninstallKeyboardActions()installKeyboardActionsからインストールされたキーボード・アクションの登録を解除します。 このメソッドは、uninstallUI()時に呼び出されます。サブクラスは、installUI時に登録されたすべてのキーボード・アクションがここで削除されるようにしてください。
- 
installListenersprotected void installListeners()JList、そのモデル、およびそのselectionModelのリスナーを作成およびインストールします。 このメソッドは、installUI()時に呼び出されます。
- 
uninstallListenersprotected void uninstallListeners()JList、そのモデル、およびそのselectionModelからリスナーを削除します。 すべてのリスナー・フィールドはここでnullにリセットされます。 このメソッドは、uninstallUI()時に呼び出されます。installListenersとの同期を保つようにしてください。
- 
installDefaultsprotected void installDefaults()リストのプロパティ(フォント、フォアグラウンド、およびバックグラウンドなど)を初期化して、CellRendererPaneを追加します。 フォント、フォアグラウンド、およびバックグラウンド・プロパティは現在の値がnullまたはUIResourceの場合にだけ設定され、ほかのプロパティは現在の値がnullの場合に設定されます。
- 
uninstallDefaultsprotected void uninstallDefaults()明示的にオーバーライドされていないリスト・プロパティをnullに設定します。 現在の値がUIResourceでなければ、プロパティはオーバーライドされたと判断されます。
- 
installUIpublic void installUI(JComponent c)installDefaults()、installListeners()、およびinstallKeyboardActions()を順番に呼び出して、this.listを初期化します。- オーバーライド:
- installUI、クラス:- ComponentUI
- パラメータ:
- c- UI委譲がインストールされるコンポーネント
- 関連項目:
- installDefaults(),- installListeners(),- installKeyboardActions()
 
- 
uninstallUIpublic void uninstallUI(JComponent c)uninstallListeners()、uninstallKeyboardActions()、およびuninstallDefaults()を順番に呼び出して、this.listの初期化を解除します。 this.listはnullに設定されます。- オーバーライド:
- uninstallUI、クラス:- ComponentUI
- パラメータ:
- c- このUI委譲が削除されるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがある
- 関連項目:
- uninstallListeners(),- uninstallKeyboardActions(),- uninstallDefaults()
 
- 
createUIpublic static ComponentUI createUI(JComponent list)BasicListUIの新しいインスタンスを返します。BasicListUIデリゲートは、JListごとに1つ割り当てられます。- パラメータ:
- list- コンポーネント
- 戻り値:
- Windowsのルック・アンド・フィールのための新しいListUI実装。
 
- 
locationToIndexリストの座標系内の特定の位置にもっとも近い、指定されたJList内のセル・インデックスを返します。 セルが実際にその指定された位置を含むかどうかを判定するには、その点と、getCellBoundsで提供されるセルの境界とを比較します。 このメソッドは、リストのモデルが空の場合、-1を返します。- 定義:
- locationToIndex、クラス:- ListUI
- パラメータ:
- list- リスト
- location- 点の座標
- 戻り値:
- 指定された位置にもっとも近いセル・インデックス、または-1
- 例外:
- NullPointerException-- locationがnullである場合
 
- 
getRowHeightprotected int getRowHeight(int row)現在のレイアウトに基づいて、指定された行の高さを返します。- パラメータ:
- row- 行
- 戻り値:
- 指定された行の高さ、または行が有効でない場合は -1
- 関連項目:
- convertYToRow(int),- convertRowToY(int),- updateLayoutState()
 
- 
convertYToRowprotected int convertYToRow(int y0)現在のレイアウトに基づいて、JList相対座標をその座標を含む行に変換します。y0がいずれの行にも含まれない場合は、 -1を返します。- パラメータ:
- y0- 相対的なY座標
- 戻り値:
- y0または -1を含む行
- 関連項目:
- getRowHeight(int),- updateLayoutState()
 
- 
convertRowToYprotected int convertRowToY(int row)JList指定された行の原点の相対的なY座標を返します。もし行が有効でない場合は -1を返します。- パラメータ:
- row- 行
- 戻り値:
- 行の原点のY座標、または -1
- 関連項目:
- getRowHeight(int),- updateLayoutState()
 
- 
maybeUpdateLayoutStateprotected void maybeUpdateLayoutState()updateLayoutStateNeededがゼロでなければ、updateLayoutState()を呼び出してupdateLayoutStateNeededをリセットします。 このメソッドは、リストのジオメトリに基づく計算をする前のメソッドで呼び出すようにしてください。 たとえば、paint()およびgetPreferredSize()で最初に呼び出します。- 関連項目:
- updateLayoutState()
 
- 
updateLayoutStateprotected void updateLayoutState()cellHeight (またはcellHeights)およびcellWidthの値を、現在のフォントと、fixedCellWidth、fixedCellHeight、およびprototypeCellValueの現在の値を基にして計算し直します。- 関連項目:
- maybeUpdateLayoutState()
 
- 
createMouseInputListenerprotected MouseInputListener createMouseInputListener()MouseInputListenerを実装するデリゲートを作成します。 デリゲートは、installUI()時間に対応するjava.awt.Componentリスナー・リストに追加されます。 サブクラスはこのメソッドをオーバーライドしてカスタムMouseInputListenerを返します。class MyListUI extends BasicListUI { protected MouseInputListener createMouseInputListener() { return new MyMouseInputHandler(); } public class MyMouseInputHandler extends MouseInputHandler { public void mouseMoved(MouseEvent e) { // do some extra work when the mouse moves super.mouseMoved(e); } } }- 戻り値:
- MouseInputListenerのインスタンス
- 関連項目:
- BasicListUI.MouseInputHandler,- installUI(javax.swing.JComponent)
 
- 
createFocusListenerprotected FocusListener createFocusListener()FocusListenerのインスタンスを返します。- 戻り値:
- FocusListenerのインスタンス
 
- 
createListSelectionListenerprotected ListSelectionListener createListSelectionListener()必要に応じてselectionModelによってJListsに追加されるListSelectionHandlerのインスタンスを作成します。 サブクラスはこのメソッドをオーバーライドしてカスタムListSelectionListenerを返します。class MyListUI extends BasicListUI { protected ListSelectionListener createListSelectionListener() { return new MySelectionListener(); } public class MySelectionListener extends ListSelectionHandler { public void valueChanged(ListSelectionEvent e) { // do some extra work when the selection changes super.valueChange(e); } } }- 戻り値:
- ListSelectionHandlerのインスタンス
- 関連項目:
- BasicListUI.ListSelectionHandler,- installUI(javax.swing.JComponent)
 
- 
createListDataListenerprotected ListDataListener createListDataListener()必要に応じてJListsにモデル別に追加されるListDataListenerのインスタンスを作成します。 サブクラスはこのメソッドをオーバーライドしてカスタムListDataListenerを返します。class MyListUI extends BasicListUI { protected ListDataListener createListDataListener() { return new MyListDataListener(); } public class MyListDataListener extends ListDataHandler { public void contentsChanged(ListDataEvent e) { // do some extra work when the models contents change super.contentsChange(e); } } }- 戻り値:
- ListDataListenerのインスタンス
- 関連項目:
- ListDataListener,- JList.getModel(),- installUI(javax.swing.JComponent)
 
- 
createPropertyChangeListenerprotected PropertyChangeListener createPropertyChangeListener()installUI()によってJListに追加されるPropertyChangeHandlerのインスタンスを作成します。 サブクラスはこのメソッドをオーバーライドしてカスタムPropertyChangeListenerを返します。class MyListUI extends BasicListUI { protected PropertyChangeListener createPropertyChangeListener() { return new MyPropertyChangeListener(); } public class MyPropertyChangeListener extends PropertyChangeHandler { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("model")) { // do some extra work when the model changes } super.propertyChange(e); } } }- 戻り値:
- PropertyChangeHandlerのインスタンス
- 関連項目:
- PropertyChangeListener,- installUI(javax.swing.JComponent)
 
 
-