- 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.ListUIで宣言されたメソッド
getCellBounds, indexToLocation
-
クラス javax.swing.plaf.ComponentUIで宣言されたメソッド
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
-
-
-
-
フィールドの詳細
-
rendererPane
protected CellRendererPane rendererPane
CellRendererPaneのインスタンス。
-
focusListener
protected FocusListener focusListener
JListに添付されたFocusListener。
-
mouseInputListener
protected MouseInputListener mouseInputListener
JListに添付されたMouseInputListener。
-
listSelectionListener
protected ListSelectionListener listSelectionListener
JListに添付されたListSelectionListener。
-
listDataListener
protected ListDataListener listDataListener
JListに添付されたListDataListener。
-
propertyChangeListener
protected PropertyChangeListener propertyChangeListener
JListに添付されたPropertyChangeListener。
-
cellHeights
protected int[] cellHeights
セルの高さの配列
-
cellHeight
protected int cellHeight
セルの高さ。
-
cellWidth
protected int cellWidth
セルの幅。
-
updateLayoutStateNeeded
protected int updateLayoutStateNeeded
この値は、JListモデルの変更を表します。
-
modelChanged
protected static final int modelChanged
このビットは、モデル変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
-
selectionModelChanged
protected static final int selectionModelChanged
このビットは、選択モデルの変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
-
fontChanged
protected static final int fontChanged
このビットは、フォントが変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
-
fixedCellWidthChanged
protected static final int fixedCellWidthChanged
このビットは、固定セル幅変更されたプロパティに関係します。- 関連項目:
- 定数フィールド値
-
fixedCellHeightChanged
protected static final int fixedCellHeightChanged
ビットは固定セルの高さ変更プロパティに関連しています。- 関連項目:
- 定数フィールド値
-
prototypeCellValueChanged
protected static final int prototypeCellValueChanged
このビットはプロト型のセル値が変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
-
cellRendererChanged
protected static final int cellRendererChanged
このビットは、セル・レンダラの変更されたプロパティに関連しています。- 関連項目:
- 定数フィールド値
-
-
メソッドの詳細
-
paintCell
protected 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)
-
paint
public 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)
-
getBaseline
public int getBaseline(JComponent c, int width, int height)
ベースラインを返します。- オーバーライド:
getBaseline、クラス:ComponentUI- パラメータ:
c- ベースラインが要求されるJComponentwidth- ベースラインを取得する幅height- ベースラインを取得する高さ- 戻り値:
- ベースラインまたは0より小さい値(適切なベースラインがないことを示す)
- 例外:
NullPointerException-cがnullである場合IllegalArgumentException- 幅または高さが0より小さい場合- 導入されたバージョン:
- 1.6
- 関連項目:
JComponent.getBaseline(int, int)
-
getBaselineResizeBehavior
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
サイズの変化に合わせてコンポーネントのベースラインがどのように変化するかを示す列挙を返します。- オーバーライド:
getBaselineResizeBehavior、クラス:ComponentUI- パラメータ:
c- ベースラインのサイズ変更の動作を返すJComponent- 戻り値:
- コンポーネント・サイズの変化に合わせてベースラインがどのように変化するかを示す列挙
- 例外:
NullPointerException-cがnullである場合- 導入されたバージョン:
- 1.6
- 関連項目:
JComponent.getBaseline(int, int)
-
getPreferredSize
public 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)
-
selectPreviousIndex
protected void selectPreviousIndex()
前の行を選択して、それを強制的に可視にします。
-
selectNextIndex
protected void selectNextIndex()
前の行を選択して、それを強制的に可視にします。
-
installKeyboardActions
protected void installKeyboardActions()
BasicListUIが関連付けられているJList上のキーボード・バインディングを登録します。 このメソッドは、installUI()時に呼び出されます。
-
uninstallKeyboardActions
protected void uninstallKeyboardActions()
installKeyboardActionsからインストールされたキーボード・アクションの登録を解除します。 このメソッドは、uninstallUI()時に呼び出されます。サブクラスは、installUI時に登録されたすべてのキーボード・アクションがここで削除されるようにしてください。
-
installListeners
protected void installListeners()
JList、そのモデル、およびそのselectionModelのリスナーを作成およびインストールします。 このメソッドは、installUI()時に呼び出されます。
-
uninstallListeners
protected void uninstallListeners()
JList、そのモデル、およびそのselectionModelからリスナーを削除します。 すべてのリスナー・フィールドはここでnullにリセットされます。 このメソッドは、uninstallUI()時に呼び出されます。installListenersとの同期を保つようにしてください。
-
installDefaults
protected void installDefaults()
リストのプロパティ(フォント、フォアグラウンド、およびバックグラウンドなど)を初期化して、CellRendererPaneを追加します。 フォント、フォアグラウンド、およびバックグラウンド・プロパティは現在の値がnullまたはUIResourceの場合にだけ設定され、ほかのプロパティは現在の値がnullの場合に設定されます。
-
uninstallDefaults
protected void uninstallDefaults()
明示的にオーバーライドされていないリスト・プロパティをnullに設定します。 現在の値がUIResourceでなければ、プロパティはオーバーライドされたと判断されます。
-
installUI
public void installUI(JComponent c)
installDefaults()、installListeners()、およびinstallKeyboardActions()を順番に呼び出して、this.listを初期化します。- オーバーライド:
installUI、クラス:ComponentUI- パラメータ:
c- UI委譲がインストールされるコンポーネント- 関連項目:
installDefaults(),installListeners(),installKeyboardActions()
-
uninstallUI
public void uninstallUI(JComponent c)
uninstallListeners()、uninstallKeyboardActions()、およびuninstallDefaults()を順番に呼び出して、this.listの初期化を解除します。 this.listはnullに設定されます。- オーバーライド:
uninstallUI、クラス:ComponentUI- パラメータ:
c- このUI委譲が削除されるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがある- 関連項目:
uninstallListeners(),uninstallKeyboardActions(),uninstallDefaults()
-
createUI
public static ComponentUI createUI(JComponent list)
BasicListUIの新しいインスタンスを返します。BasicListUIデリゲートは、JListごとに1つ割り当てられます。- パラメータ:
list- コンポーネント- 戻り値:
- Windowsのルック・アンド・フィールのための新しい
ListUI実装。
-
locationToIndex
public int locationToIndex(JList<?> list, Point location)
リストの座標系内の特定の位置にもっとも近い、指定されたJList内のセル・インデックスを返します。 セルが実際にその指定された位置を含むかどうかを判定するには、その点と、getCellBoundsで提供されるセルの境界とを比較します。 このメソッドは、リストのモデルが空の場合、-1を返します。- 定義:
locationToIndex、クラス:ListUI- パラメータ:
list- リストlocation- 点の座標- 戻り値:
- 指定された位置にもっとも近いセル・インデックス、または
-1 - 例外:
NullPointerException-locationがnullである場合
-
getRowHeight
protected int getRowHeight(int row)
現在のレイアウトに基づいて、指定された行の高さを返します。- パラメータ:
row- 行- 戻り値:
- 指定された行の高さ、または行が有効でない場合は -1
- 関連項目:
convertYToRow(int),convertRowToY(int),updateLayoutState()
-
convertYToRow
protected int convertYToRow(int y0)
現在のレイアウトに基づいて、JList相対座標をその座標を含む行に変換します。y0がいずれの行にも含まれない場合は、 -1を返します。- パラメータ:
y0- 相対的なY座標- 戻り値:
- y0または -1を含む行
- 関連項目:
getRowHeight(int),updateLayoutState()
-
convertRowToY
protected int convertRowToY(int row)
JList指定された行の原点の相対的なY座標を返します。もし行が有効でない場合は -1を返します。- パラメータ:
row- 行- 戻り値:
- 行の原点のY座標、または -1
- 関連項目:
getRowHeight(int),updateLayoutState()
-
maybeUpdateLayoutState
protected void maybeUpdateLayoutState()
updateLayoutStateNeededがゼロでなければ、updateLayoutState()を呼び出してupdateLayoutStateNeededをリセットします。 このメソッドは、リストのジオメトリに基づく計算をする前のメソッドで呼び出すようにしてください。 たとえば、paint()およびgetPreferredSize()で最初に呼び出します。- 関連項目:
updateLayoutState()
-
updateLayoutState
protected void updateLayoutState()
cellHeight (またはcellHeights)およびcellWidthの値を、現在のフォントと、fixedCellWidth、fixedCellHeight、およびprototypeCellValueの現在の値を基にして計算し直します。- 関連項目:
maybeUpdateLayoutState()
-
createMouseInputListener
protected 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)
-
createFocusListener
protected FocusListener createFocusListener()
FocusListenerのインスタンスを返します。- 戻り値:
FocusListenerのインスタンス
-
createListSelectionListener
protected 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)
-
createListDataListener
protected 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)
-
createPropertyChangeListener
protected 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)
-
-