モジュール java.desktop
パッケージ javax.swing.plaf.basic

クラスBasicListUI

直系の既知のサブクラス:
SynthListUI

public class BasicListUI
extends ListUI
ListUIの拡張実装です。

BasicListUIインスタンスは複数のリスト間で共有できません。

  • ネストされたクラスのサマリー

    ネストされたクラス 
    修飾子と型 クラス 説明
    class  BasicListUI.FocusHandler
    このクラスは、「protected」内部クラスとして扱うようにしてください。
    class  BasicListUI.ListDataHandler
    installUI timeJListsモデルに追加されるListDataListener、およびJList.modelプロパティが変更されるたびに追加されます。
    class  BasicListUI.ListSelectionHandler
    installUI時およびJList.selectionModelプロパティ変更時にJLists選択モデルに追加されるListSelectionListenerです。
    class  BasicListUI.MouseInputHandler
    JListのためのマウス入力およびフォーカス処理です。
    class  BasicListUI.PropertyChangeHandler
    installUI時にJListに追加されるPropertyChangeListenerです。
  • フィールドのサマリー

    フィールド 
    修飾子と型 フィールド 説明
    protected int cellHeight
    セルの高さ。
    protected int[] cellHeights
    セルの高さの配列
    protected static int cellRendererChanged
    このビットは、セル・レンダラの変更されたプロパティに関連しています。
    protected int cellWidth
    セルの幅。
    protected static int fixedCellHeightChanged
    ビットは固定セルの高さ変更プロパティに関連しています。
    protected static int fixedCellWidthChanged
    このビットは、固定セル幅変更されたプロパティに関係します。
    protected FocusListener focusListener
    JListに添付されたFocusListener
    protected static int fontChanged
    このビットは、フォントが変更されたプロパティに関連しています。
    protected JList<Object> list
    JListのインスタンス。
    protected ListDataListener listDataListener
    JListに添付されたListDataListener
    protected ListSelectionListener listSelectionListener
    JListに添付されたListSelectionListener
    protected static int modelChanged
    このビットは、モデル変更されたプロパティに関連しています。
    protected MouseInputListener mouseInputListener
    JListに添付されたMouseInputListener
    protected PropertyChangeListener propertyChangeListener
    JListに添付されたPropertyChangeListener
    protected static int prototypeCellValueChanged
    このビットはプロト型のセル値が変更されたプロパティに関連しています。
    protected CellRendererPane rendererPane
    CellRendererPaneのインスタンス。
    protected static int selectionModelChanged
    このビットは、選択モデルの変更されたプロパティに関連しています。
    protected int updateLayoutStateNeeded
    この値は、JListモデルの変更を表します。
  • コンストラクタのサマリー

    コンストラクタ 
    コンストラクタ 説明
    BasicListUI()  
  • メソッドのサマリー

    修飾子と型 メソッド 説明
    protected int convertRowToY​(int row)
    JList指定された行の原点の相対的なY座標を返します。もし行が有効でない場合は -1を返します。
    protected int convertYToRow​(int y0)
    現在のレイアウトに基づいて、JList相対座標をその座標を含む行に変換します。
    protected FocusListener createFocusListener()
    FocusListenerのインスタンスを返します。
    protected ListDataListener createListDataListener()
    必要に応じてJListsにモデル別に追加されるListDataListenerのインスタンスを作成します。
    protected ListSelectionListener createListSelectionListener()
    必要に応じてselectionModelによってJListsに追加されるListSelectionHandlerのインスタンスを作成します。
    protected MouseInputListener createMouseInputListener()
    MouseInputListenerを実装するデリゲートを作成します。
    protected PropertyChangeListener createPropertyChangeListener()
    installUI()によってJListに追加されるPropertyChangeHandlerのインスタンスを作成します。
    static ComponentUI createUI​(JComponent list)
    BasicListUIの新しいインスタンスを返します。
    int getBaseline​(JComponent c, int width, int height)
    ベースラインを返します。
    Component.BaselineResizeBehavior getBaselineResizeBehavior​(JComponent c)
    サイズの変化に合わせてコンポーネントのベースラインがどのように変化するかを示す列挙を返します。
    Dimension getPreferredSize​(JComponent c)
    リストのpreferredSizeはレイアウト方向によって決まります。
    protected int getRowHeight​(int row)
    現在のレイアウトに基づいて、指定された行の高さを返します。
    protected void installDefaults()
    リストのプロパティ(フォント、フォアグラウンド、およびバックグラウンドなど)を初期化して、CellRendererPaneを追加します。
    protected void installKeyboardActions()
    BasicListUIが関連付けられているJList上のキーボード・バインディングを登録します。
    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<Object> cellRenderer, ListModel<Object> dataModel, ListSelectionModel selModel, int leadIndex)
    リスト・セルをペイント: 関連する状態をコンピュートし、"ラバー・スタンプ"セル・レンダラ・コンポーネントを取得し、CellRendererPaneを使用してペイントします。
    protected void selectNextIndex()
    前の行を選択して、それを強制的に可視にします。
    protected void selectPreviousIndex()
    前の行を選択して、それを強制的に可視にします。
    protected void uninstallDefaults()
    明示的にオーバーライドされていないリスト・プロパティをnullに設定します。
    protected void uninstallKeyboardActions()
    installKeyboardActionsからインストールされたキーボード・アクションの登録を解除します。
    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.ListUIで宣言されたメソッド

    getCellBounds, indexToLocation

    クラス javax.swing.plaf.ComponentUIで宣言されたメソッド

    contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update

    クラス java.lang.Objectで宣言されたメソッド

    cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait
  • フィールド詳細

  • コンストラクタの詳細

  • メソッドの詳細

    • 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 - ベースラインが要求されるJComponent
      width - ベースラインを取得する幅
      height - ベースラインを取得する高さ
      戻り値:
      ベースラインまたは0より小さい値(適切なベースラインがないことを示す)
      例外:
      NullPointerException - cnullである場合
      IllegalArgumentException - 幅または高さが0より小さい場合
      導入されたバージョン:
      1.6
      関連項目:
      JComponent.getBaseline(int, int)
    • getBaselineResizeBehavior

      public Component.BaselineResizeBehavior getBaselineResizeBehavior​(JComponent c)
      サイズの変化に合わせてコンポーネントのベースラインがどのように変化するかを示す列挙を返します。
      オーバーライド:
      getBaselineResizeBehavior、クラス: ComponentUI
      パラメータ:
      c - ベースラインのサイズ変更の動作を返すJComponent
      戻り値:
      コンポーネント・サイズの変化に合わせてベースラインがどのように変化するかを示す列挙
      例外:
      NullPointerException - cnullである場合
      導入されたバージョン:
      1.6
      関連項目:
      JComponent.getBaseline(int, int)
    • getPreferredSize

      public Dimension getPreferredSize​(JComponent c)
      リストのpreferredSizeはレイアウト方向によって決まります。
      配置方向ごとに推奨サイズを記述します。
      配置方向 推奨サイズ
      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.left+insets.right、結果の推奨される高さは、上記の高さ+insets.top+insets.bottomです。 Insetslist.getInsets()から決まります。
      オーバーライド:
      getPreferredSize、クラス: ComponentUI
      パラメータ:
      c - JListコンポーネント。
      戻り値:
      リストの総サイズ。
      関連項目:
      JComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)
    • selectPreviousIndex

      protected void selectPreviousIndex()
      前の行を選択して、それを強制的に可視にします。
      関連項目:
      JList.ensureIndexIsVisible(int)
    • selectNextIndex

      protected void selectNextIndex()
      前の行を選択して、それを強制的に可視にします。
      関連項目:
      JList.ensureIndexIsVisible(int)
    • installKeyboardActions

      protected void installKeyboardActions()
      BasicListUIが関連付けられているJList上のキーボード・バインディングを登録します。 このメソッドは、installUI()時に呼び出されます。
      関連項目:
      installUI(javax.swing.JComponent)
    • uninstallKeyboardActions

      protected void uninstallKeyboardActions()
      installKeyboardActionsからインストールされたキーボード・アクションの登録を解除します。 このメソッドは、uninstallUI()時に呼び出されます。サブクラスは、installUI時に登録されたすべてのキーボード・アクションがここで削除されるようにしてください。
      関連項目:
      installUI(javax.swing.JComponent)
    • installListeners

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

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

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

      protected void uninstallDefaults()
      明示的にオーバーライドされていないリスト・プロパティをnullに設定します。 現在の値がUIResourceでなければ、プロパティはオーバーライドされたと判断されます。
      関連項目:
      installDefaults(), uninstallUI(javax.swing.JComponent), CellRendererPane
    • 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)