public class DefaultTreeSelectionModel extends Object implements Cloneable, Serializable, TreeSelectionModel
resetRowSelectionは選択されたパスを更新するメソッドから呼び出されます。 選択できるものをフィルタリングするために、これらのメソッドのどれかをサブクラス化する場合、スーパー・クラスにメッセージを送っていなければ、必ずresetRowSelectionメッセージを送るようにします。 警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースとの互換性がなくなる予定です。 現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。 1.4以降、すべてのJavaBeans™用の長期間の格納サポートが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モデルと見なされます。
現在の選択範囲が新しいモードに対して有効でない場合、選択範囲は変更されます。 たとえば、3つのTreePathが選択された状態でモードをSINGLE_TREE_SELECTIONに変更した場合、一つの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.EventListenerの下位インタフェースを指定FooListenerとして登録されたすべてのオブジェクトの配列、またはこのようなリスナーが追加されていない場合は空の配列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, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。