|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Objectjavax.swing.tree.DefaultTreeSelectionModel
public class DefaultTreeSelectionModel
TreeSelectionModel のデフォルト実装です。リスナーは、行が変更されたときではなく選択範囲のパスが変更されたときに通知を受けます。行の変更を追跡できるようにするには、ツリー上で展開イベントのリスナーになることにより、行の変更を判定します。
resetRowSelection は選択されたパスを更新するメソッドから呼び出されます。選択できるものをフィルタリングするために、これらのメソッドのどれかをサブクラス化する場合、スーパークラスにメッセージを送っていなければ、必ず resetRowSelection メッセージを送るようにします。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。JDK バージョン 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 のどれかになります。 |
| インタフェース javax.swing.tree.TreeSelectionModel から継承されたフィールド |
|---|
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION |
| コンストラクタの概要 | |
|---|---|
DefaultTreeSelectionModel()
空の新しい DefaultTreeSelectionMode のインスタンスを生成します。 |
|
| メソッドの概要 | ||
|---|---|---|
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()
選択範囲のリードインデックスを返します。 |
|
|
getListeners(Class<T> listenerType)
このモデルに FooListener として現在登録されているすべてのオブジェクトの配列を返します。 |
|
int |
getMaxSelectionRow()
選択した現在の TreePath の設定の RowMapper から取得した最大値を返します。 |
|
int |
getMinSelectionRow()
選択した現在の TreePath の設定の RowMapper から取得した最小値を返します。 |
|
PropertyChangeListener[] |
getPropertyChangeListeners()
この DefaultTreeSelectionModel に登録された、すべてのプロパティ変更リスナーから成る配列を返します。 |
|
RowMapper |
getRowMapper()
TreePath を行にマップできる RowMapper のインスタンスを返します。 |
|
int |
getSelectionCount()
選択されているパスの数を返します。 |
|
int |
getSelectionMode()
現在の選択モードを返します。 |
|
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<javax.swing.tree.PathPlaceHolder> changedPaths,
TreePath oldLeadSelection)
path 内の変更をリスナーに通知します。 |
|
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)
選択モデルを設定します。 |
|
void |
setSelectionPath(TreePath path)
選択範囲をパスに設定します。 |
|
void |
setSelectionPaths(TreePath[] pPaths)
選択範囲を paths のパスに設定します。 |
|
String |
toString()
このオブジェクトのプロパティを表示および識別する文字列を返します。 |
|
protected void |
updateLeadIndex()
leadIndex インスタンス変数を更新します。 |
|
| クラス java.lang.Object から継承されたメソッド |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| フィールドの詳細 |
|---|
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)
TreeSelectionModel 内の setRowMapperpublic RowMapper getRowMapper()
TreeSelectionModel 内の getRowMapperpublic void setSelectionMode(int mode)
DISCONTIGUOUS_TREE_SELECTION モデルと見なされます。
現在の選択範囲が新しいモードに対して有効でない場合は選択範囲を変更できます。たとえば、モードが SINGLE_TREE_SELECTION に変更したときに 3 つの TreePath が選択された場合、1 つの TreePath だけを選択できます。どの TreePath を選択するかは使用する特定の実装によって決まります。
モードを定義されていないタイプに設定すると、モードは DISCONTIGUOUS_TREE_SELECTION になります。
TreeSelectionModel 内の setSelectionModepublic int getSelectionMode()
SINGLE_TREE_SELECTION、DISCONTIGUOUS_TREE_SELECTION、CONTIGUOUS_TREE_SELECTION のどれかになります。
TreeSelectionModel 内の getSelectionModepublic void setSelectionPath(TreePath path)
path が null の場合は clearSelection を呼び出した場合と同じになります。
TreeSelectionModel 内の setSelectionPathpath - 選択する新しいパスpublic void setSelectionPaths(TreePath[] pPaths)
paths が null の場合、これは clearSelection を呼び出すのと同じ効果があります。
リードパスは pPaths の最後のパスに設定されます。
選択モードが CONTIGUOUS_TREE_SELECTION の場合に、新規パスの追加により選択範囲が不連続になると、選択範囲は paths の最初の TreePath にリセットされます。
TreeSelectionModel 内の setSelectionPathspPaths - 新しい選択範囲public void addSelectionPath(TreePath path)
path が null の場合は影響はありません。
TreeSelectionModel 内の addSelectionPathpath - 現在の選択範囲に追加する新しいパスpublic void addSelectionPaths(TreePath[] paths)
path が null の場合は影響はありません。
リードパスは paths の最後のパスに設定されます。
選択モードが CONTIGUOUS_TREE_SELECTION の場合、パスを新たに追加すると選択範囲が不連続になります。つまり、選択範囲が 2 つになります。paths の TreePath が連続している場合は、選択範囲はこれらの TreePath になります。そうでない場合は、TreePath が連続していないので、選択範囲は paths の最初の TreePath になります。
TreeSelectionModel 内の addSelectionPathspaths - 現在の選択範囲に追加する新しいパスpublic void removeSelectionPath(TreePath path)
path が null の場合は影響はありません。
TreeSelectionModel 内の removeSelectionPathpath - 選択範囲から削除するパスpublic void removeSelectionPaths(TreePath[] paths)
paths が null の場合は影響はありません。
TreeSelectionModel 内の removeSelectionPathspaths - 選択範囲から削除するパスpublic TreePath getSelectionPath()
TreeSelectionModel 内の getSelectionPathpublic TreePath[] getSelectionPaths()
TreeSelectionModel 内の getSelectionPathspublic int getSelectionCount()
TreeSelectionModel 内の getSelectionCountpublic boolean isPathSelected(TreePath path)
path が現在の選択範囲にある場合に true を返します。
TreeSelectionModel 内の isPathSelectedpublic boolean isSelectionEmpty()
TreeSelectionModel 内の isSelectionEmptypublic void clearSelection()
TreeSelectionModel 内の clearSelectionpublic void addTreeSelectionListener(TreeSelectionListener x)
TreeSelectionModel 内の addTreeSelectionListenerx - 追加される新しいリスナーpublic void removeTreeSelectionListener(TreeSelectionListener x)
TreeSelectionModel 内の removeTreeSelectionListenerx - 削除するリスナーpublic TreeSelectionListener[] getTreeSelectionListeners()
TreeSelectionListener。ツリー選択リスナーが登録されていない場合は空の配列addTreeSelectionListener(javax.swing.event.TreeSelectionListener),
removeTreeSelectionListener(javax.swing.event.TreeSelectionListener)protected void fireValueChanged(TreeSelectionEvent e)
addTreeSelectionListener(javax.swing.event.TreeSelectionListener),
EventListenerListpublic <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()
TreeSelectionModel 内の getSelectionRowspublic int getMinSelectionRow()
TreeSelectionModel 内の getMinSelectionRowpublic int getMaxSelectionRow()
TreeSelectionModel 内の getMaxSelectionRowpublic boolean isRowSelected(int row)
row で識別される行が選択されている場合に true を返します。
TreeSelectionModel 内の isRowSelectedpublic void resetRowSelection()
通常は呼び出す必要はありません。JTree とそれに関連する Listeners が呼び出します。独自の View クラスを実装中の場合は自分で呼び出す必要があります。
insureRowContinuity を呼び出して、現在選択されている TreePaths がまだ選択モードで有効であることを確認します。
TreeSelectionModel 内の resetRowSelectionpublic int getLeadSelectionRow()
TreeSelectionModel 内の getLeadSelectionRowpublic TreePath getLeadSelectionPath()
TreeSelectionModel 内の getLeadSelectionPathpublic void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeEvent は、選択範囲モードが変更されるとトリガされます。
TreeSelectionModel 内の addPropertyChangeListenerlistener - 追加する PropertyChangeListenerpublic void removePropertyChangeListener(PropertyChangeListener listener)
TreeSelectionModel 内の removePropertyChangeListenerlistener - 削除する 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)
protected void notifyPathChange(Vector<javax.swing.tree.PathPlaceHolder> changedPaths,
TreePath oldLeadSelection)
protected void updateLeadIndex()
protected void insureUniqueness()
public String toString()
Object 内の toString
public Object clone()
throws CloneNotSupportedException
Object 内の cloneCloneNotSupportedException - このクラスのインスタンスでスローされないCloneable
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。