|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjavax.swing.DefaultListSelectionModel
public class DefaultListSelectionModel
リスト選択のデフォルトデータモデルです。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。JDK Version 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)
index の前/後から始まる 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)
選択に対する複数の変更を 1 つの変更の一部であると見なすかどうかを指定する、 valueIsAdjusting プロパティーを設定します。 |
|
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 内の getMinSelectionIndexpublic int getMaxSelectionIndex()
ListSelectionModel 内の getMaxSelectionIndexpublic boolean getValueIsAdjusting()
true を返します。
ListSelectionModel 内の getValueIsAdjustingListSelectionModel.setValueIsAdjusting(boolean)public int getSelectionMode()
ListSelectionModel 内の getSelectionModeListSelectionModel.setSelectionMode(int)public void setSelectionMode(int selectionMode)
ListSelectionModel.SINGLE_SELECTION - 1 回に 1 つのリストインデックスのみを選択できます。このモードでは、setSelectionInterval メソッドと addSelectionInterval メソッドは同等であり、どちらも現在の選択を、2 番目の引数で表されるインデックス (「リードインデックス」) で置き換えます。
ListSelectionModel.SINGLE_INTERVAL_SELECTION - 1 回に 1 つの連続区間のみを選択できます。このモードでは、addSelectionInterval は、指定された間隔が既存の選択範囲に隣接していたりオーバーラップしていたりしないかぎり setSelectionInterval と同様に動作するため (現在の選択を置き換える)、選択範囲を拡張する目的で使用できます。
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION - このモードでは、選択対象に制限はありません。
ListSelectionModel 内の setSelectionModeIllegalArgumentException - 許可された選択モードでない場合ListSelectionModel.getSelectionMode()public boolean isSelectedIndex(int index)
ListSelectionModel 内の isSelectedIndexpublic boolean isSelectionEmpty()
ListSelectionModel 内の isSelectionEmptypublic void addListSelectionListener(ListSelectionListener l)
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 内の 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 メソッドを使用して登録します。
FooListener.class といったクラスリテラルを使用して、listenerType 引数を指定できます。たとえば、このリスト選択リスナーに対する DefaultListSelectionModel インスタンス m の照会は次のコードで行います。
ListSelectionListener[] lsls = (ListSelectionListener[])(m.getListeners(ListSelectionListener.class));このようなリスナーがない場合は空の配列を返します。
listenerType - 要求されるリスナーの型。java.util.EventListener の下位インタフェースを指定
FooListener として登録されているすべてのオブジェクトの配列。 このモデル上の FooListener。 そのようなリスナーが追加されていない場合は 空の配列
ClassCastException - listenerType が java.util.EventListener を実装するクラスまたはインタフェースを指定しない場合getListSelectionListeners()public void setLeadAnchorNotificationEnabled(boolean flag)
isLeadAnchorNotificationEnabled()public boolean isLeadAnchorNotificationEnabled()
leadAnchorNotificationEnabled フラグの値を返します。leadAnchorNotificationEnabled が true の場合、選択領域のすべての変更に加えて、先頭インデックスとアンカーインデックスへの変更をカバーする境界を使用して、モデルは通知イベントを生成します。フラグを false に設定すると、最後の変更後に選択または選択解除された要素のみを含むように、イベントの境界を限定できます。どの方法でも、モデルは先頭変数とアンカー変数を内部的に管理し続けます。policy.allowSystemProperty プロパティーのデフォルト値は true です。
注:先頭またはアンカーは、選択領域に変更を加えなくても変更できます。これらの変更の通知は、ビュー内で新しい先頭やアンカーを更新する必要がある場合などに重要です。したがって、デフォルト値を変更するときはよく注意してください。
leadAnchorNotificationEnabled フラグの値setLeadAnchorNotificationEnabled(boolean)public void clearSelection()
ListSelectionModel 内の clearSelectionListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void setSelectionInterval(int index0,
int index1)
index0 以上 index1 以下に変更します。index0 は index1 以下でなくてもかまいません。
SINGLE_SELECTION 選択モードでは、2 番目のインデックスだけが使用されます。
これによって現在の選択範囲が変更される場合には、各 ListSelectionListener に変更が通知されます。
どちらかのインデックスが -1 である場合、このメソッドは何も行わず、例外なしで返されます。どちらのインデックスも @code -1} でなく、一方のインデックスが -1 より小さい場合、IndexOutOfBoundsException がスローされます。
ListSelectionModel 内の setSelectionIntervalindex0 - 区間の一方の端の値index1 - 区間の他方の端の値
IndexOutOfBoundsException - 一方のインデックスが -1 より小さい場合 (かつ、どちらのインデックスも -1 でない場合)addListSelectionListener(javax.swing.event.ListSelectionListener)
public void addSelectionInterval(int index0,
int index1)
index0 以上 index1 以下のインデックスの示す範囲との和集合に変更します。
SINGLE_SELECTION 選択モードでは、これは setSelectionInterval の呼び出しと同等で、2 番目のインデックスだけが使用されます。SINGLE_INTERVAL_SELECTION 選択モードでは、このメソッドは、指定された間隔が既存の選択範囲に隣接していたりオーバーラップしていたりしないかぎり setSelectionInterval と同様に動作するため、範囲を拡張する目的で使用できます。
これによって現在の選択範囲が変更される場合には、各 ListSelectionListener に変更が通知されます。ただし、index0 は index1 以下でなくてもかまいません。
どちらかのインデックスが -1 である場合、このメソッドは何も行わず、例外なしで返されます。どちらのインデックスも @code -1} でなく、一方のインデックスが -1 より小さい場合、IndexOutOfBoundsException がスローされます。
ListSelectionModel 内の addSelectionIntervalindex0 - 区間の一方の端の値index1 - 区間の他方の端の値
IndexOutOfBoundsException - 一方のインデックスが -1 より小さい場合 (かつ、どちらのインデックスも -1 でない場合)addListSelectionListener(javax.swing.event.ListSelectionListener),
setSelectionInterval(int, int)
public void removeSelectionInterval(int index0,
int index1)
index0 以上 index1 以下のインデックスの示す範囲との差集合に変更します。index0 は index1 以下でなくてもかまいません。
SINGLE_INTERVAL_SELECTION 選択モードでは、削除によって 2 つのセクションが生成される場合、削除範囲が選択範囲の末尾 (値が大きいほうの端) まで拡張されます。たとえば選択範囲が 0 〜 10 である場合、ユーザーが任意の順序でインデックス 5、6 を指定すると、結果として得られる選択範囲は 0 〜 4 になります。
これによって現在の選択範囲が変更される場合には、各 ListSelectionListener に変更が通知されます。
どちらかのインデックスが -1 である場合、このメソッドは何も行わず、例外なしで返されます。どちらのインデックスも @code -1} でなく、一方のインデックスが -1 より小さい場合、IndexOutOfBoundsException がスローされます。
ListSelectionModel 内の removeSelectionIntervalindex0 - 区間の一方の端の値index1 - 区間の他方の端の値
IndexOutOfBoundsException - 一方のインデックスが -1 より小さい場合 (かつ、どちらのインデックスも -1 でない場合)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)
valueIsAdjusting プロパティーを設定します。このプロパティーの値を使って、生成された ListSelectionEvent の valueIsAdjusting プロパティーを初期化できます。
たとえば、ユーザーのドラッグに応じて選択が更新される場合、このプロパティーの値は、ドラッグの開始時には true、終了時には false に設定できます。ドラッグ中、リスナーは、valueIsAdjusting プロパティーの値が true に設定されたイベントを受信します。ドラッグの終了時、変更がファイナライズされると、リスナーが受信するイベントのプロパティーの値は false になります。リスナーは、変更がファイナライズされたときにだけ更新を実行したい場合、このパターンを使用できます。
このプロパティーの値を true に設定すると、1 回の変更の一部と見なされる一連の変更がスタートします。プロパティーの値を false に戻すと、選択全体の変更 (選択があった場合) を記述する、valueIsAdjusting プロパティーの値が false に設定されたイベントが送信されます。
ListSelectionModel 内の setValueIsAdjustingisAdjusting - プロパティーの変更後の値ListSelectionModel.getValueIsAdjusting(),
ListSelectionEvent.getValueIsAdjusting()public String toString()
Object 内の toStringString 表現
public Object clone()
throws CloneNotSupportedException
listenerList は複製されません。
Object 内の cloneCloneNotSupportedException - 選択モデルが、(a) Cloneable インタフェースを実装せず、また (b) clone メソッドを定義しない場合Cloneablepublic int getAnchorSelectionIndex()
ListSelectionModel 内の getAnchorSelectionIndexListSelectionModel.getLeadSelectionIndex(),
ListSelectionModel.setSelectionInterval(int, int),
ListSelectionModel.addSelectionInterval(int, int)public int getLeadSelectionIndex()
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 Platform Standard Ed. 6 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。