|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjavax.swing.DefaultListSelectionModel
public class DefaultListSelectionModel
リスト選択のデフォルトデータモデルです。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。JDK バージョン 1.4 以降、すべての JavaBeans™ の長期間の運用サポートは、java.beans パッケージに追加されています。詳細は、XMLEncoder を参照してください。
ListSelectionModel| フィールドの概要 | |
|---|---|
protected boolean |
leadAnchorNotificationEnabled
|
protected EventListenerList |
listenerList
|
| インタフェース javax.swing.ListSelectionModel から継承されたフィールド |
|---|
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION |
| コンストラクタの概要 | |
|---|---|
DefaultListSelectionModel()
|
|
| メソッドの概要 | ||
|---|---|---|
void |
addListSelectionListener(ListSelectionListener l)
選択範囲の変更が通知されるリスナーをリストに追加します。 |
|
void |
addSelectionInterval(int index0,
int index1)
選択範囲を、現在の選択範囲と index0 以上 index1 以下のインデックスの示す範囲との和集合に変更します。 |
|
void |
clearSelection()
選択範囲を空のセットに変更します。 |
|
Object |
clone()
この選択モデルの複製を、同じ選択状態で返します。 |
|
protected void |
fireValueChanged(boolean isAdjusting)
一連の調整が終了したことをリスナーに通知します。 |
|
protected void |
fireValueChanged(int firstIndex,
int lastIndex)
firstIndex、lastIndex 間で選択の値が変更されたことを ListSelectionListeners に通知します。 |
|
protected void |
fireValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting)
|
|
int |
getAnchorSelectionIndex()
setSelectionInterval()、addSelectionInterval()、または removeSelectionInterval() の直前の呼び出しから、最初のインデックス引数を返します。 |
|
int |
getLeadSelectionIndex()
setSelectionInterval()、addSelectionInterval()、または removeSelectionInterval() の直前の呼び出しから、2 番目のインデックス引数を返します。 |
|
|
getListeners(Class<T> listenerType)
このモデルに FooListener として現在登録されているすべてのオブジェクトの配列を返します。 |
|
ListSelectionListener[] |
getListSelectionListeners()
この DefaultListSelectionModel に登録されているすべてのリスト選択リスナーの配列を返します。 |
|
int |
getMaxSelectionIndex()
最後に選択されたインデックスを返すか、選択範囲が空の場合に -1 を返します。 |
|
int |
getMinSelectionIndex()
最初に選択されたインデックスを返すか、選択範囲が空の場合に -1 を返します。 |
|
int |
getSelectionMode()
選択モードを返します。 |
|
boolean |
getValueIsAdjusting()
値が一連の変更を受けている場合に true を返します。 |
|
void |
insertIndexInterval(int index,
int length,
boolean before)
インデックスの前または後で始まる length インデックスを挿入します。 |
|
boolean |
isLeadAnchorNotificationEnabled()
leadAnchorNotificationEnabled フラグの値を返します。 |
|
boolean |
isSelectedIndex(int index)
指定のインデックスが選択されている場合に true を返します。 |
|
boolean |
isSelectionEmpty()
インデックスが選択されていない場合に true を返します。 |
|
void |
moveLeadSelectionIndex(int leadIndex)
先頭の選択インデックスを設定して、すべての選択値を未変更のままにします。 |
|
void |
removeIndexInterval(int index0,
int index1)
index0 と index1 の間 (これらの値を含む) のインデックスを選択モデルから削除します。 |
|
void |
removeListSelectionListener(ListSelectionListener l)
選択範囲の変更が通知されるリスナーをリストから削除します。 |
|
void |
removeSelectionInterval(int index0,
int index1)
選択範囲を、現在の選択範囲と index0 以上 index1 以下のインデックスの示す範囲との差集合に変更します。 |
|
void |
setAnchorSelectionIndex(int anchorIndex)
アンカー選択インデックスを設定して、すべての選択値を変更しないままにします。 |
|
void |
setLeadAnchorNotificationEnabled(boolean flag)
leadAnchorNotificationEnabled フラグの値を設定します。 |
|
void |
setLeadSelectionIndex(int leadIndex)
先頭の選択インデックスを設定し、アンカーと新しい先頭の間の値が、すべて選択またはすべて選択解除のどちらかであることを保証します。 |
|
void |
setSelectionInterval(int index0,
int index1)
選択範囲を index0 以上 index1 以下に変更します。 |
|
void |
setSelectionMode(int selectionMode)
選択モードを設定します。 |
|
void |
setValueIsAdjusting(boolean isAdjusting)
このプロパティは、モデルの値に適用されつつある変更が単一のイベントと考えられる場合に true になります。 |
|
String |
toString()
このオブジェクトのプロパティを表示および識別する文字列を返します。 |
|
| クラス java.lang.Object から継承されたメソッド |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| フィールドの詳細 |
|---|
protected EventListenerList listenerList
protected boolean leadAnchorNotificationEnabled
| コンストラクタの詳細 |
|---|
public DefaultListSelectionModel()
| メソッドの詳細 |
|---|
public int getMinSelectionIndex()
ListSelectionModel の記述:
ListSelectionModel 内の getMinSelectionIndexpublic int getMaxSelectionIndex()
ListSelectionModel の記述:
ListSelectionModel 内の getMaxSelectionIndexpublic boolean getValueIsAdjusting()
ListSelectionModel の記述:
ListSelectionModel 内の getValueIsAdjustingListSelectionModel.setValueIsAdjusting(boolean)public int getSelectionMode()
ListSelectionModel 内の getSelectionModegetSelectionMode()public void setSelectionMode(int selectionMode)
ListSelectionModel 内の setSelectionModeselectionMode - 次の 3 つの値のどれかIllegalArgumentException - selectionMode が上記の正当な値のリストにない場合setSelectionMode(int)public boolean isSelectedIndex(int index)
ListSelectionModel の記述:
ListSelectionModel 内の isSelectedIndexpublic boolean isSelectionEmpty()
ListSelectionModel の記述:
ListSelectionModel 内の isSelectionEmptypublic void addListSelectionListener(ListSelectionListener l)
ListSelectionModel の記述:
ListSelectionModel 内の addListSelectionListenerl - ListSelectionListenerListSelectionModel.removeListSelectionListener(javax.swing.event.ListSelectionListener),
ListSelectionModel.setSelectionInterval(int, int),
ListSelectionModel.addSelectionInterval(int, int),
ListSelectionModel.removeSelectionInterval(int, int),
ListSelectionModel.clearSelection(),
ListSelectionModel.insertIndexInterval(int, int, boolean),
ListSelectionModel.removeIndexInterval(int, int)public void removeListSelectionListener(ListSelectionListener l)
ListSelectionModel の記述:
ListSelectionModel 内の removeListSelectionListenerl - ListSelectionListenerListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)public ListSelectionListener[] getListSelectionListeners()
DefaultListSelectionModel に登録されているすべてのリスト選択リスナーの配列を返します。
ListSelectionListener。リスト選択リスナーが現在登録されていない場合は空の配列を返すaddListSelectionListener(javax.swing.event.ListSelectionListener),
removeListSelectionListener(javax.swing.event.ListSelectionListener)protected void fireValueChanged(boolean isAdjusting)
protected void fireValueChanged(int firstIndex,
int lastIndex)
firstIndex、lastIndex 間で選択の値が変更されたことを ListSelectionListeners に通知します。
protected void fireValueChanged(int firstIndex,
int lastIndex,
boolean isAdjusting)
firstIndex - 範囲の先頭のインデックスlastIndex - 範囲の最後のインデックスisAdjusting - 一連の調整の最後の変更である場合は trueEventListenerListpublic <T extends EventListener> T[] getListeners(Class<T> listenerType)
FooListener として現在登録されているすべてのオブジェクトの配列を返します。この FooListener は addFooListener メソッドで登録されたものです。
listenerType 引数は FooListener.class のようなクラスリテラルで指定できます。たとえば、このリスト選択リスナーに対する DefaultListSelectionModel インスタンス m の照会は次のコードで行います。
ListSelectionListener[] lsls = (ListSelectionListener[])(m.getListeners(ListSelectionListener.class));このようなリスナーがない場合は空の配列を返します。
listenerType - 要求されるリスナーの型。java.util.EventListener の下位インタフェースを指定
FooListener として登録されているすべてのオブジェクトの配列。リスナーが登録されていない場合は空の配列を返す
ClassCastException - listenerType が java.util.EventListener を実装するクラスまたはインタフェースを指定しない場合getListSelectionListeners()public void setLeadAnchorNotificationEnabled(boolean flag)
isLeadAnchorNotificationEnabled()public boolean isLeadAnchorNotificationEnabled()
leadAnchorNotificationEnabled フラグの値を返します。leadAnchorNotificationEnabled が true の場合、選択領域のすべての変更に加えて、先頭インデックスとアンカーインデックスへの変更をカバーする境界を使用して、モデルは通知イベントを生成します。フラグを false に設定すると、最後の変更後に選択または選択解除された要素のみを含むように、イベントの境界を限定できます。どの方法でも、モデルは先頭変数とアンカー変数を内部的に管理し続けます。デフォルトは true です。
注: 先頭またはアンカーは、選択領域に変更を加えなくても変更できます。これらの変更の通知は、ビュー内で新しい先頭やアンカーを更新する必要がある場合などに重要です。したがって、デフォルト値を変更するときはよく注意してください。
leadAnchorNotificationEnabled フラグの値setLeadAnchorNotificationEnabled(boolean)public void clearSelection()
ListSelectionModel の記述:
ListSelectionModel 内の clearSelectionListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void setSelectionInterval(int index0,
int index1)
ListSelectionModel の記述:
ListSelectionModel 内の setSelectionIntervalindex0 - 区間の一方の端の値index1 - 区間の他方の端の値ListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void addSelectionInterval(int index0,
int index1)
ListSelectionModel の記述:
ListSelectionModel 内の addSelectionIntervalindex0 - 区間の一方の端の値index1 - 区間の他方の端の値ListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void removeSelectionInterval(int index0,
int index1)
ListSelectionModel の記述:
ListSelectionModel 内の removeSelectionIntervalindex0 - 区間の一方の端の値index1 - 区間の他方の端の値ListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void insertIndexInterval(int index,
int length,
boolean before)
ListSelectionModel 内の insertIndexInterval
public void removeIndexInterval(int index0,
int index1)
ListSelectionModel 内の removeIndexIntervalpublic void setValueIsAdjusting(boolean isAdjusting)
ListSelectionModel の記述:
ListSelectionModel 内の setValueIsAdjustingisAdjusting - プロパティの新しい値ListSelectionModel.getValueIsAdjusting()public String toString()
Object 内の toStringString 表現
public Object clone()
throws CloneNotSupportedException
listenerList は複製されません。
Object 内の cloneCloneNotSupportedException - 選択モデルが、(a) Cloneable インタフェースを実装せず、また (b) clone メソッドを定義しない場合Cloneablepublic int getAnchorSelectionIndex()
ListSelectionModel の記述:
ListSelectionModel 内の getAnchorSelectionIndexListSelectionModel.getLeadSelectionIndex(),
ListSelectionModel.setSelectionInterval(int, int),
ListSelectionModel.addSelectionInterval(int, int)public int getLeadSelectionIndex()
ListSelectionModel の記述:
ListSelectionModel 内の getLeadSelectionIndexListSelectionModel.getAnchorSelectionIndex(),
ListSelectionModel.setSelectionInterval(int, int),
ListSelectionModel.addSelectionInterval(int, int)public void setAnchorSelectionIndex(int anchorIndex)
ListSelectionModel 内の setAnchorSelectionIndexgetAnchorSelectionIndex(),
setLeadSelectionIndex(int)public void moveLeadSelectionIndex(int leadIndex)
leadIndex - 新しい先頭の選択インデックスsetAnchorSelectionIndex(int),
setLeadSelectionIndex(int),
getLeadSelectionIndex()public void setLeadSelectionIndex(int leadIndex)
アンカーインデックスの値が選択されていない場合、同じことを逆に行います。つまり古い範囲の値を選択してから新しい範囲の値を選択解除します。
この変更のイベントを 1 つ生成し、すべてのリスナーに通知します。このイベント内で最小限の境界を生成するため、1 回のパスで操作を行います。この方法では、ブロードキャストされた ListSelectionEvent 内の先頭と末尾のインデックスは、このメソッドによって実際に値が変更されたセルを参照します。この操作を 2 回のステップで処理すると、選択状態の効果は同じでも、2 つのイベントが生成されてしまいます。さらに、後で設定されるためだけにクリアされるセルが発生してしまい、変更対象の値に関連して操作される領域が広くなります。
このメソッドを UI クラスの mouseDragged メソッドで使用すると、選択を拡張できます。
ListSelectionModel 内の setLeadSelectionIndexgetLeadSelectionIndex(),
setAnchorSelectionIndex(int)
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。