Java Reference
In-Depth Information
methods to describe the selected set of paths to the selected nodes. Each path is stored in a
TreePath , which itself contains a path of tree nodes from the root object to a selected node. The
TreePath class will be explored shortly.
public interface TreeSelectionModel {
// Constants
public final static int CONTIGUOUS_TREE_SELECTION;
public final static int DISCONTIGUOUS_TREE_SELECTION;
public final static int SINGLE_TREE_SELECTION;
// Properties
public TreePath getLeadSelectionPath();
public int getLeadSelectionRow();
public int getMaxSelectionRow();
public int getMinSelectionRow();
public RowMapper getRowMapper();
public void setRowMapper(RowMapper newMapper);
public int getSelectionCount();
public boolean isSelectionEmpty();
public int getSelectionMode();
public void setSelectionMode(int mode);
public TreePath getSelectionPath();
public void setSelectionPath(TreePath path);
public TreePath[] getSelectionPaths();
public void setSelectionPaths(TreePath paths[]);
public int[] getSelectionRows();
// Listeners
public void addPropertyChangeListener(PropertyChangeListener listener);
public void removePropertyChangeListener(PropertyChangeListener listener);
public void addTreeSelectionListener(TreeSelectionListener listener);
public void removeTreeSelectionListener(TreeSelectionListener listener);
// Other methods
public void addSelectionPath(TreePath path);
public void addSelectionPaths(TreePath paths[]);
public void clearSelection();
public boolean isPathSelected(TreePath path);
public boolean isRowSelected(int row);
public void removeSelectionPath(TreePath path);
public void removeSelectionPaths(TreePath paths[]);
public void resetRowSelection();
}
The TreeSelectionModel interface supports three modes of selection, with each mode
specified by a class constant: CONTIGUOUS_TREE_SELECTION , DISCONTIGUOUS_TREE_SELECTION , or
SINGLE_TREE_SELECTION . When the selection mode is CONTIGUOUS_TREE_SELECTION , only nodes
situated next to each other can be selected simultaneously. The DISCONTIGUOUS_TREE_SELECTION
mode means that there are no restrictions on simultaneous selection. With the remaining mode,
SINGLE_TREE_SELECTION , only one node can be selected at a time. If you don't want anything to be
selectable, use a setting of null . This uses the protected JTree.EmptySelectionModel class.
Search WWH ::




Custom Search