JavaTM 2 Platform
Std. Ed. v1.3

javax.swing.plaf.basic
クラス BasicListUI

java.lang.Object
  |
  +--javax.swing.plaf.ComponentUI
        |
        +--javax.swing.plaf.ListUI
              |
              +--javax.swing.plaf.basic.BasicListUI

public class BasicListUI
extends ListUI

ListUI の Windows Look & Feel による実装です。


内部クラスの概要
 class BasicListUI.FocusHandler
          この内部クラスは public とマークされますが、これはコンパイラのバグが原因です。
 class BasicListUI.ListDataHandler
          installUI の実行時、および JList.model プロパティが変更された時に JList モデルに追加される ListDataListener です。
 class BasicListUI.ListSelectionHandler
          installUI の実行時、および JList.selectionModel プロパティが変更された時に JLists の選択範囲モデルに追加される ListSelectionListener です。
 class BasicListUI.MouseInputHandler
          JList でのマウス入力、およびフォーカス処理を行います。
 class BasicListUI.PropertyChangeHandler
          PropertyChangeListener は、installUI の実行時に JList に追加されます。
 
フィールドの概要
protected  int cellHeight
           
protected  int[] cellHeights
           
protected static int cellRendererChanged
           
protected  int cellWidth
           
protected static int fixedCellHeightChanged
           
protected static int fixedCellWidthChanged
           
protected  FocusListener focusListener
           
protected static int fontChanged
           
protected  JList list
           
protected  ListDataListener listDataListener
           
protected  ListSelectionListener listSelectionListener
           
protected static int modelChanged
           
protected  MouseInputListener mouseInputListener
           
protected  PropertyChangeListener propertyChangeListener
           
protected static int prototypeCellValueChanged
           
protected  CellRendererPane rendererPane
           
protected static int selectionModelChanged
           
protected  int updateLayoutStateNeeded
           
 
コンストラクタの概要
BasicListUI()
           
 
メソッドの概要
protected  int convertRowToY(int row)
          指定された行の原点の相対 Y 座標を返します。
protected  int convertYToRow(int y0)
          JList の相対座標を、現在のレイアウトを基にして、座標を含む行に変換します。
protected  FocusListener createFocusListener()
           
protected  ListDataListener createListDataListener()
          モデルによって必要に応じて JList に追加される、ListDataListener のインスタンスを生成します。
protected  ListSelectionListener createListSelectionListener()
          selectionModel によって必要に応じて JList に追加される、ListSelectionHandler のインスタンスを生成します。
protected  MouseInputListener createMouseInputListener()
          MouseInputListener を実装する委譲を作成します。
protected  PropertyChangeListener createPropertyChangeListener()
          installUI() によって JList に追加される、PropertyChangeHandler のインスタンスを生成します。
static ComponentUI createUI(JComponent list)
          BasicListUI の新しいインスタンスを返します。
 Rectangle getCellBounds(JList list, int index1, int index2)
          指定された項目の JList 座標における境界を返します。
 Dimension getMaximumSize(JComponent c)
           
 Dimension getMinimumSize(JComponent c)
           
 Dimension getPreferredSize(JComponent c)
          リストの最適なサイズは、行の高さの合計と、セルの最大幅です。
protected  int getRowHeight(int row)
          現在のレイアウトで、指定された行の高さを返します。
 Point indexToLocation(JList list, int index)
          指定された項目の JList 座標における原点を返します。
protected  void installDefaults()
          JList のプロパティ (フォント、フォアグラウンド、およびバックグラウンドなど) を初期化して、CellRendererPane を追加します。
protected  void installKeyboardActions()
          上矢印キー、および下矢印キーのキーボードアクションを登録します。
protected  void installListeners()
          JList、そのモデル、および selectionModel のリスナーを作成およびインストールします。
 void installUI(JComponent c)
          installDefaults()installListeners()、および installKeyboardActions() を順に呼び出して、this.list を初期化します。
 int locationToIndex(JList list, Point location)
          JList の座標上の点をその位置にあるセルのインデックスに変換します。
protected  void maybeUpdateLayoutState()
          updateLayoutStateNeeded がゼロでなければ、updateLayoutState() を呼び出して updateLayoutStateNeeded をリセットします。
 void paint(Graphics g, JComponent c)
          Graphics オブジェクトの clipRect と交差する行をペイントします。
protected  void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex)
          List のセルを 1 つペイントします。
protected  void selectNextIndex()
          1 つ後の行を選択して、それを強制的に可視にします。
protected  void selectPreviousIndex()
          1 つ前の行を選択して、それを強制的に可視にします。
protected  void uninstallDefaults()
          null に明示的にオーバーライドされていない JList のプロパティを設定します。
protected  void uninstallKeyboardActions()
          上矢印キー、および下矢印キーのキーボードアクションの登録を解除します。
protected  void uninstallListeners()
          JList、そのモデル、および selectionModel のリスナーを削除します。
 void uninstallUI(JComponent c)
          uninstallListeners()uninstallKeyboardActions()、および uninstallDefaults() を順に呼び出して、this.list の初期化を解除します。
protected  void updateLayoutState()
          cellHeight (または cellHeights) および cellWidth の値を、現在のフォントと、fixedCellWidth、fixedCellHeight、および prototypeCellValue の現在の値を基にして計算し直します。
 
クラス javax.swing.plaf.ComponentUI から継承したメソッド
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

list

protected JList list

rendererPane

protected CellRendererPane rendererPane

focusListener

protected FocusListener focusListener

mouseInputListener

protected MouseInputListener mouseInputListener

listSelectionListener

protected ListSelectionListener listSelectionListener

listDataListener

protected ListDataListener listDataListener

propertyChangeListener

protected PropertyChangeListener propertyChangeListener

cellHeights

protected int[] cellHeights

cellHeight

protected int cellHeight

cellWidth

protected int cellWidth

updateLayoutStateNeeded

protected int updateLayoutStateNeeded

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
コンストラクタの詳細

BasicListUI

public BasicListUI()
メソッドの詳細

paintCell

protected void paintCell(Graphics g,
                         int row,
                         Rectangle rowBounds,
                         ListCellRenderer cellRenderer,
                         ListModel dataModel,
                         ListSelectionModel selModel,
                         int leadIndex)
List のセルを 1 つペイントします。適切な状態を計算し、セルレンダリングコンポーネントの「ラバースタンプ」を取得してから、CellRendererPane を使ってセルをペイントします。サブクラスでは、paint() ではなくこのメソッドをオーバーライドすることができます。
関連項目:
paint(java.awt.Graphics, javax.swing.JComponent)

paint

public void paint(Graphics g,
                  JComponent c)
Graphics オブジェクトの clipRect と交差する行をペイントします。このメソッドは、必要に応じて paintCell を呼び出します。サブクラスは、これらのメソッドをオーバーライドすることができます。
オーバーライド:
クラス ComponentUI 内の paint
関連項目:
paintCell(java.awt.Graphics, int, java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, javax.swing.ListSelectionModel, int)

getPreferredSize

public Dimension getPreferredSize(JComponent c)
リストの最適なサイズは、行の高さの合計と、セルの最大幅です。JList.fixedCellHeight が指定されている場合、行の高さの合計は (cellVerticalMargins + fixedCellHeight) * model.getSize() になります。ここで rowVerticalMargins は、フォーカスを示す黄色いアウトラインを描画するために割り当てる領域に相当します。同様に、JList.fixedCellWidth が指定されている場合は、セルの固定幅に水平方向のマージンが加算されます。
オーバーライド:
クラス ComponentUI 内の getPreferredSize
パラメータ:
c - JList コンポーネント
戻り値:
リストの総サイズ

getMinimumSize

public Dimension getMinimumSize(JComponent c)
オーバーライド:
クラス ComponentUI 内の getMinimumSize
戻り値:
適切なサイズ
関連項目:
getPreferredSize(javax.swing.JComponent)

getMaximumSize

public Dimension getMaximumSize(JComponent c)
オーバーライド:
クラス ComponentUI 内の getMaximumSize
戻り値:
適切なサイズ
関連項目:
getPreferredSize(javax.swing.JComponent)

selectPreviousIndex

protected void selectPreviousIndex()
1 つ前の行を選択して、それを強制的に可視にします。KeyEvent.VK_UP キーボードアクションで呼び出されます。
関連項目:
installKeyboardActions(), JList.ensureIndexIsVisible(int)

selectNextIndex

protected void selectNextIndex()
1 つ後の行を選択して、それを強制的に可視にします。KeyEvent.VK_DOWN キーボードアクションで呼び出されます。
関連項目:
installKeyboardActions(), JList.ensureIndexIsVisible(int)

installKeyboardActions

protected void installKeyboardActions()
上矢印キー、および下矢印キーのキーボードアクションを登録します。これらのアクションは protected メソッドを呼び出すだけなので、キーボードの動作をオーバーライドあるいは拡張するサブクラスは、これらのメソッドのオーバーライドを検討してください。このメソッドは、installUI() の実行時に呼び出されます。
関連項目:
selectPreviousIndex(), selectNextIndex(), installUI(javax.swing.JComponent)

uninstallKeyboardActions

protected void uninstallKeyboardActions()
上矢印キー、および下矢印キーのキーボードアクションの登録を解除します。このメソッドは、uninstallUI() の実行時に呼び出されます。サブクラスは、installUI の実行時に登録されたキーボードアクションをすべて、ここで削除するようにしてください。
関連項目:
selectPreviousIndex(), selectNextIndex(), installUI(javax.swing.JComponent)

installListeners

protected void installListeners()
JList、そのモデル、および selectionModel のリスナーを作成およびインストールします。このメソッドは、installUI() の実行時に呼び出されます。
関連項目:
installUI(javax.swing.JComponent), uninstallListeners()

uninstallListeners

protected void uninstallListeners()
JList、そのモデル、および selectionModel のリスナーを削除します。ここで、リスナーのフィールドはすべて null にリセットされます。このメソッドは、uninstallUI() の実行時に呼び出されます。installListners との同期を保つようにしてください。
関連項目:
uninstallUI(javax.swing.JComponent), installListeners()

installDefaults

protected void installDefaults()
JList のプロパティ (フォント、フォアグラウンド、およびバックグラウンドなど) を初期化して、CellRendererPane を追加します。フォント、フォアグラウンド、およびバックグラウンドの各プロパティは、それらの現在の値が null か UIResource である場合にだけ設定されます。その他のプロパティは、現在の値が null である場合に設定されます。
関連項目:
uninstallDefaults(), installUI(javax.swing.JComponent), CellRendererPane

uninstallDefaults

protected void uninstallDefaults()
null に明示的にオーバーライドされていない JList のプロパティを設定します。現在の値が UIResouce でなければ、プロパティはオーバーライドされたと判断されます。
関連項目:
installDefaults(), uninstallUI(javax.swing.JComponent), CellRendererPane

installUI

public void installUI(JComponent c)
installDefaults()installListeners()、および installKeyboardActions() を順に呼び出して、this.list を初期化します。
オーバーライド:
クラス ComponentUI 内の installUI
関連項目:
installDefaults(), installListeners(), installKeyboardActions()

uninstallUI

public void uninstallUI(JComponent c)
uninstallListeners()uninstallKeyboardActions()、および uninstallDefaults() を順に呼び出して、this.list の初期化を解除します。this.list は null に設定されます。
オーバーライド:
クラス ComponentUI 内の uninstallUI
関連項目:
uninstallListeners(), uninstallKeyboardActions(), uninstallDefaults()

createUI

public static ComponentUI createUI(JComponent list)
BasicListUI の新しいインスタンスを返します。BasicListUI の委譲は、JList 1 つに付き 1 つが割り当てられます。
戻り値:
Winodws Look & Feel のための、新しい ListUI の実装

locationToIndex

public int locationToIndex(JList list,
                           Point location)
クラス ListUI の記述:
JList の座標上の点をその位置にあるセルのインデックスに変換します。指定された位置にセルが存在しない場合は、-1 を返します。
オーバーライド:
クラス ListUI 内の locationToIndex
戻り値:
指定された位置にあるセルのインデックス、または -1
関連項目:
ListUI.locationToIndex(javax.swing.JList, java.awt.Point)

indexToLocation

public Point indexToLocation(JList list,
                             int index)
クラス ListUI の記述:
指定された項目の JList 座標における原点を返します。無効なインデックスを指定した場合は、null を返します。
オーバーライド:
クラス ListUI 内の indexToLocation
戻り値:
index で指定された番号のセルの原点。index が無効の場合は null
関連項目:
ListUI.indexToLocation(javax.swing.JList, int)

getCellBounds

public Rectangle getCellBounds(JList list,
                               int index1,
                               int index2)
クラス ListUI の記述:
指定された項目の JList 座標における境界を返します。無効なインデックスを指定した場合は、null を返します。
オーバーライド:
クラス ListUI 内の getCellBounds
戻り値:
index で指定された番号のセルの境界
関連項目:
ListUI.getCellBounds(javax.swing.JList, int, int)

getRowHeight

protected int getRowHeight(int row)
現在のレイアウトで、指定された行の高さを返します。
戻り値:
指定された行の高さ。行の指定が無効な場合は -1
関連項目:
convertYToRow(int), convertRowToY(int), updateLayoutState()

convertYToRow

protected int convertYToRow(int y0)
JList の相対座標を、現在のレイアウトを基にして、座標を含む行に変換します。y0 がどの行にも含まれない場合は、-1 を返します。
戻り値:
y0 を含む行、または -1
関連項目:
getRowHeight(int), updateLayoutState()

convertRowToY

protected int convertRowToY(int row)
指定された行の原点の相対 Y 座標を返します。行が無効な場合は -1 を返します。
戻り値:
行の原点の 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);
        }
    }
 }
 
関連項目:
BasicListUI.MouseInputHandler, installUI(javax.swing.JComponent)

createFocusListener

protected FocusListener createFocusListener()

createListSelectionListener

protected ListSelectionListener createListSelectionListener()
selectionModel によって必要に応じて JList に追加される、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);
        }
    }
 }
 
関連項目:
BasicListUI.ListSelectionHandler, installUI(javax.swing.JComponent)

createListDataListener

protected ListDataListener createListDataListener()
モデルによって必要に応じて JList に追加される、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, 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);
        }
    }
 }
 
関連項目:
PropertyChangeListener, installUI(javax.swing.JComponent)

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.