public class DefaultTreeSelectionModel extends Object implements Cloneable, Serializable, TreeSelectionModel
resetRowSelection は選択されたパスを更新するメソッドから呼び出されます。選択できるものをフィルタリングするために、これらのメソッドのどれかをサブクラス化する場合、スーパークラスにメッセージを送っていなければ、必ず resetRowSelection メッセージを送るようにします。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースとの互換性がなくなる予定です。現在の直列化のサポートは、短期間の格納や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。1.4 以降、すべての JavaBeansTM 用の長期間の格納サポートが java.beans パッケージに追加されています。XMLEncoder を参照してください。
JTree| 修飾子と型 | フィールドと説明 |
|---|---|
protected SwingPropertyChangeSupport |
changeSupport
メッセージを受け取る登録済みリスナーのために使います。
|
protected int |
leadIndex
選択範囲のリードパスのインデックスです。
|
protected TreePath |
leadPath
追加された最後のパスです。
|
protected int |
leadRow
リード行です。
|
protected EventListenerList |
listenerList
イベントリスナーリストです。
|
protected DefaultListSelectionModel |
listSelectionModel
リスト選択モデルの更新を処理します。
|
protected RowMapper |
rowMapper
指定のパスに行を提供します。
|
protected TreePath[] |
selection
現在選択されているパスです。
|
static String |
SELECTION_MODE_PROPERTY
selectionMode のプロパティー名です。
|
protected int |
selectionMode
選択モードは、SINGLE_TREE_SELECTION、CONTIGUOUS_TREE_SELECTION、DISCONTIGUOUS_TREE_SELECTION のどれかになります。
|
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION| コンストラクタと説明 |
|---|
DefaultTreeSelectionModel()
空の新しい DefaultTreeSelectionMode のインスタンスを生成します。生成されたインスタンスの選択モードは DISCONTIGUOUS_TREE_SELECTION です。
|
| 修飾子と型 | メソッドと説明 |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener をリスナーリストに追加します。
|
void |
addSelectionPath(TreePath path)
現在の選択範囲にパスを追加します。
|
void |
addSelectionPaths(TreePath[] paths)
現在の選択範囲にパスを追加します。
|
void |
addTreeSelectionListener(TreeSelectionListener x)
選択された TreePath の設定が変更されるたびに通知を受けるリスナーのリストに x を追加します。
|
protected boolean |
arePathsContiguous(TreePath[] paths)
パスが連続しているか、このオブジェクトに RowMapper がない場合、true を返します。
|
protected boolean |
canPathsBeAdded(TreePath[] paths)
TreePath の特定のセットが追加できるかどうか判定するために使用します。 |
protected boolean |
canPathsBeRemoved(TreePath[] paths)
モデルの連続性を壊さずにパスを削除できる場合に true を返します。
|
void |
clearSelection()
現在の選択範囲を空にします。
|
Object |
clone()
同じ選択範囲を持つこのオブジェクトの複製を返します。
|
protected void |
fireValueChanged(TreeSelectionEvent e)
このオブジェクトのツリー選択イベントの対象として登録しているリスナーすべてに通知します。
|
TreePath |
getLeadSelectionPath()
追加された最後のパスを返します。
|
int |
getLeadSelectionRow()
選択範囲のリードインデックスを返します。
|
<T extends EventListener> |
getListeners(Class<T> listenerType)
このモデルに
FooListener として現在登録されているすべてのオブジェクトの配列を返します。 |
int |
getMaxSelectionRow()
選択した現在の TreePath の設定の RowMapper から取得した最大値を返します。
|
int |
getMinSelectionRow()
選択した現在の TreePath の設定の RowMapper から取得した最小値を返します。
|
PropertyChangeListener[] |
getPropertyChangeListeners()
この
DefaultTreeSelectionModel に登録されているすべてのプロパティー変更リスナーの配列を返します。 |
RowMapper |
getRowMapper()
TreePath を行にマップできる RowMapper のインスタンスを返します。
|
int |
getSelectionCount()
選択されているパスの数を返します。
|
int |
getSelectionMode()
選択モードを返します。これは、
SINGLE_TREE_SELECTION、DISCONTIGUOUS_TREE_SELECTION、または CONTIGUOUS_TREE_SELECTION のいずれかになります。 |
TreePath |
getSelectionPath()
選択範囲の先頭のパスを返します。
|
TreePath[] |
getSelectionPaths()
選択範囲を返します。
|
int[] |
getSelectionRows()
行の選択を返します。
|
TreeSelectionListener[] |
getTreeSelectionListeners()
このモデルに登録された、すべてのツリー選択リスナーから成る配列を返します。
|
protected void |
insureRowContinuity()
現在選択されている
TreePath が現在の選択モードで有効であるかを確認します。 |
protected void |
insureUniqueness()
このメソッドは廃止されたため、その実装は操作不能です。
|
boolean |
isPathSelected(TreePath path)
パス
path が現在の選択範囲にある場合に true を返します。 |
boolean |
isRowSelected(int row)
row で識別される行が選択されている場合に true を返します。 |
boolean |
isSelectionEmpty()
選択範囲が現在空の場合に true を返します。
|
protected void |
notifyPathChange(Vector changedPaths, TreePath oldLeadSelection)
非推奨。
JDK version 1.7 以降
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener をリスナーリストから削除します。
|
void |
removeSelectionPath(TreePath path)
選択範囲からパスを削除します。
|
void |
removeSelectionPaths(TreePath[] paths)
選択範囲からパスを削除します。
|
void |
removeTreeSelectionListener(TreeSelectionListener x)
選択された TreePath の設定が変更されるたびに通知を受けるリスナーのリストから x を削除します。
|
void |
resetRowSelection()
このオブジェクトの TreePath から行へのマッピングを更新します。
|
void |
setRowMapper(RowMapper newMapper)
RowMapper のインスタンスを設定します。
|
void |
setSelectionMode(int mode)
選択モードを設定します。このモードは、SINGLE_TREE_SELECTION、CONTIGUOUS_TREE_SELECTION、DISCONTIGUOUS_TREE_SELECTION のどれか 1 つである必要があります。
|
void |
setSelectionPath(TreePath path)
選択範囲をパスに設定します。
|
void |
setSelectionPaths(TreePath[] pPaths)
選択範囲を設定します。
|
String |
toString()
このオブジェクトのプロパティーを表示および識別する文字列を返します。
|
protected void |
updateLeadIndex()
leadIndex インスタンス変数を更新します。
|
public static final String SELECTION_MODE_PROPERTY
protected SwingPropertyChangeSupport changeSupport
protected TreePath[] selection
protected EventListenerList listenerList
protected transient RowMapper rowMapper
protected DefaultListSelectionModel listSelectionModel
protected int selectionMode
protected TreePath leadPath
protected int leadIndex
protected int leadRow
public DefaultTreeSelectionModel()
public void setRowMapper(RowMapper newMapper)
setRowMapper、インタフェース: TreeSelectionModelpublic RowMapper getRowMapper()
getRowMapper、インタフェース: TreeSelectionModelpublic void setSelectionMode(int mode)
DISCONTIGUOUS_TREE_SELECTION モデルと見なされます。
現在の選択範囲が新しいモードに対して有効でない場合は選択範囲を変更できます。たとえば、モードが SINGLE_TREE_SELECTION に変更されたときに 3 つの TreePath が選択された場合、1 つの TreePath だけが選択されます。どの TreePath を選択するかは使用する特定の実装によって決まります。
モードを定義されていないタイプに設定すると、モードは DISCONTIGUOUS_TREE_SELECTION になります。
setSelectionMode、インタフェース: TreeSelectionModelpublic int getSelectionMode()
SINGLE_TREE_SELECTION、DISCONTIGUOUS_TREE_SELECTION、または CONTIGUOUS_TREE_SELECTION のいずれかになります。getSelectionMode、インタフェース: TreeSelectionModelpublic void setSelectionPath(TreePath path)
path が null の場合は clearSelection を呼び出した場合と同じ効果があります。setSelectionPath、インタフェース: TreeSelectionModelpath - 選択する新しいパスpublic void setSelectionPaths(TreePath[] pPaths)
null または空の場合は、選択範囲がクリアされます。選択モードが SINGLE_TREE_SELECTION の場合は、pPaths の最初のパスだけが使用されます。選択モードが CONTIGUOUS_TREE_SELECTION で、指定されたパスが連続していない場合は、pPaths の最初のパスだけが使用されます。選択モードが DISCONTIGUOUS_TREE_SELECTION の場合は、すべてのパスが使用されます。
pPaths の null パスはすべて無視されます。
これが変更を表す場合は、登録されているすべての TreeSelectionListener が通知を受けます。
リードパスは最後の一意のパスに設定されます。
getSelectionPaths から返されるパスの順序は、このメソッドに指定されたパスと同じです。
setSelectionPaths、インタフェース: TreeSelectionModelpPaths - 新しい選択範囲public void addSelectionPath(TreePath path)
path が null の場合は影響はありません。addSelectionPath、インタフェース: TreeSelectionModelpath - 現在の選択範囲に追加する新しいパスpublic void addSelectionPaths(TreePath[] paths)
paths が null の場合は影響はありません。
リードパスは paths の最後のパスに設定されます。
選択モードが CONTIGUOUS_TREE_SELECTION の場合、パスを新たに追加すると選択範囲が不連続になります。つまり、選択範囲が 2 つになります。paths の TreePath が連続している場合は、選択範囲はこれらの TreePath になります。そうでない場合は、TreePath が連続していないので、選択範囲は paths の最初の TreePath になります。
addSelectionPaths、インタフェース: TreeSelectionModelpaths - 現在の選択範囲に追加する新しいパスpublic void removeSelectionPath(TreePath path)
path が null の場合は影響はありません。removeSelectionPath、インタフェース: TreeSelectionModelpath - 選択範囲から削除するパスpublic void removeSelectionPaths(TreePath[] paths)
paths が null の場合は影響はありません。removeSelectionPaths、インタフェース: TreeSelectionModelpaths - 選択範囲から削除するパスpublic TreePath getSelectionPath()
getSelectionPath、インタフェース: TreeSelectionModelpublic TreePath[] getSelectionPaths()
getSelectionPaths、インタフェース: TreeSelectionModelpublic int getSelectionCount()
getSelectionCount、インタフェース: TreeSelectionModelpublic boolean isPathSelected(TreePath path)
path が現在の選択範囲にある場合に true を返します。isPathSelected、インタフェース: TreeSelectionModelpublic boolean isSelectionEmpty()
isSelectionEmpty、インタフェース: TreeSelectionModelpublic void clearSelection()
clearSelection、インタフェース: TreeSelectionModelpublic void addTreeSelectionListener(TreeSelectionListener x)
addTreeSelectionListener、インタフェース: TreeSelectionModelx - 追加される新しいリスナーpublic void removeTreeSelectionListener(TreeSelectionListener x)
removeTreeSelectionListener、インタフェース: TreeSelectionModelx - 削除するリスナーpublic TreeSelectionListener[] getTreeSelectionListeners()
TreeSelectionListener 全部。ツリー選択リスナーが現在登録されていない場合は空の配列addTreeSelectionListener(javax.swing.event.TreeSelectionListener), removeTreeSelectionListener(javax.swing.event.TreeSelectionListener)protected void fireValueChanged(TreeSelectionEvent e)
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
FooListener として現在登録されているすべてのオブジェクトの配列を返します。FooListener は、addFooListener メソッドを使用して登録されます。
FooListener.class などのクラスリテラルを使用して listenerType 引数を指定できます。たとえば、次のコードを使用して、DefaultTreeSelectionModel m をそのツリー選択リスナーに照会できます。
TreeSelectionListener[] tsls = (TreeSelectionListener[])(m.getListeners(TreeSelectionListener.class));このようなリスナーがない場合は空の配列を返します。
listenerType - 要求されるリスナーの型。次の下位インタフェースを指定: java.util.EventListenerFooListener として登録されたすべてのオブジェクトの配列、またはこのようなリスナーが追加されていない場合は空の配列ClassCastException - listenerType で、java.util.EventListener を実装するクラスまたはインタフェースが指定されなかった場合getTreeSelectionListeners(), getPropertyChangeListeners()public int[] getSelectionRows()
getSelectionPaths から返される TreePath とこのメソッドとの間には、必ずしも 1 対 1 のマッピングがあるとは限りません。特に、TreePath が表示可能でない (RowMapper が TreePath に対応する行に対して -1 を返す) 場合は、対応する行が返される配列に含まれません。たとえば、選択範囲が A と B の 2 つのパス (行 10 に A があり、B は現在表示可能でない) で構成される場合、このメソッドは単一のエントリ 10 を含む配列を返します。getSelectionRows、インタフェース: TreeSelectionModelpublic int getMinSelectionRow()
getMinSelectionRow、インタフェース: TreeSelectionModelpublic int getMaxSelectionRow()
getMaxSelectionRow、インタフェース: TreeSelectionModelpublic boolean isRowSelected(int row)
row で識別される行が選択されている場合に true を返します。isRowSelected、インタフェース: TreeSelectionModelpublic void resetRowSelection()
通常は呼び出す必要はありません。JTree とそれに関連する Listeners が呼び出します。独自の View クラスを実装中の場合は自分で呼び出す必要があります。
insureRowContinuity を呼び出して、現在選択されている TreePaths がまだ選択モードで有効であることを確認します。
resetRowSelection、インタフェース: TreeSelectionModelpublic int getLeadSelectionRow()
getLeadSelectionRow、インタフェース: TreeSelectionModelpublic TreePath getLeadSelectionPath()
getLeadSelectionPath、インタフェース: TreeSelectionModelpublic void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeEvent は、選択範囲モードが変更されるとトリガーされます。
addPropertyChangeListener、インタフェース: TreeSelectionModellistener - 追加される PropertyChangeListenerpublic void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener、インタフェース: TreeSelectionModellistener - 削除される PropertyChangeListenerpublic PropertyChangeListener[] getPropertyChangeListeners()
DefaultTreeSelectionModel に登録されているすべてのプロパティー変更リスナーの配列を返します。PropertyChangeListener。現在プロパティー変更リスナーが登録されていない場合は空の配列addPropertyChangeListener(java.beans.PropertyChangeListener), removePropertyChangeListener(java.beans.PropertyChangeListener)protected void insureRowContinuity()
TreePath が現在の選択モードで有効であるかを確認します。選択モードが CONTIGUOUS_TREE_SELECTION のときに RowMapper が存在している場合、このメソッドはすべての行が連続しているか (ソートしたときに、すべての行が間隔を空けずに順序よく並んでいるか) を確認します。選択範囲が連続してない場合は、ソートしたときに連続した行の最初のセットが含まれるようにリセットされます。
選択モードが SINGLE_TREE_SELECTION の場合に、複数の TreePath が選択されると、選択範囲は、現在選択されている最初のパスを含むようにリセットされます。
protected boolean arePathsContiguous(TreePath[] paths)
protected boolean canPathsBeAdded(TreePath[] paths)
TreePath の特定のセットが追加できるかどうか判定するために使用します。paths が null (または空) の場合、このオブジェクトが RowMapper を持たない場合、現在選択されていない場合、選択モードが DISCONTIGUOUS_TREE_SELECTION の場合、または現在の選択範囲にパスを追加しても、TreePath が連続設定である場合に、true を返します。protected boolean canPathsBeRemoved(TreePath[] paths)
@Deprecated protected void notifyPathChange(Vector changedPaths, TreePath oldLeadSelection)
protected void updateLeadIndex()
protected void insureUniqueness()
public String toString()
public Object clone() throws CloneNotSupportedException
clone、クラス: ObjectCloneNotSupportedException - このクラスのインスタンスではスローされないCloneable バグまたは機能を送信
詳細な API リファレンスおよび開発者ドキュメントについては、Java SE のドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.