📄 treeselectionmodel.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:42:45 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface TreeSelectionModel</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/TreeSelectionModel.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/swing/tree/TreeNode.html"><B>PREV CLASS</B></A> NEXT CLASS</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="TreeSelectionModel.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.swing.tree</FONT><BR>Interface TreeSelectionModel</H2><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../javax/swing/tree/DefaultTreeSelectionModel.html">DefaultTreeSelectionModel</A></DD></DL><HR><DL><DT>public interface <B>TreeSelectionModel</B></DL><P>This interface represents the current state of the selection for the tree component. For information and examples of using tree selection models, see <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html">How to Use Trees</a> in <em>The Java Tutorial.</em> <p> The state of the tree selection is characterized by a set of TreePaths, and optionally a set of integers. The mapping from TreePath to integer is done by way of an instance of RowMapper. It is not necessary for a TreeSelectionModel to have a RowMapper to correctly operate, but without a RowMapper <code>getSelectionRows</code> will return null. <p> A TreeSelectionModel can be configured to allow only one path (<code>SINGLE_TREE_SELECTION</code>) a number of continguous paths (<code>CONTIGUOUS_TREE_SELECTION</code>) or a number of discontiguous paths (<code>DISCONTIGUOUS_TREE_SELECTION</code>). A <code>RowMapper</code> is used to determine if TreePaths are contiguous. In the absence of a RowMapper <code>CONTIGUOUS_TREE_SELECTION</code> and <code>DISCONTIGUOUS_TREE_SELECTION</code> behave the same, that is they allow any number of paths to be contained in the TreeSelectionModel. <p> For a selection model of <code>CONTIGUOUS_TREE_SELECTION</code> any time the paths are changed (<code>setSelectionPath</code>, <code>addSelectionPath</code> ...) the TreePaths are again checked to make they are contiguous. A check of the TreePaths can also be forced by invoking <code>resetRowSelection</code>. How a set of discontiguous TreePaths is mapped to a contiguous set is left to implementors of this interface to enforce a particular policy. <p> Implementations should combine duplicate TreePaths that are added to the selection. For example, the following code <pre> TreePath[] paths = new TreePath[] { treePath, treePath }; treeSelectionModel.setSelectionPaths(paths); </pre> should result in only one path being selected: <code>treePath</code>, and not two copies of <code>treePath</code>. <p> The lead TreePath is the last path that was added (or set). The lead row is then the row that corresponds to the TreePath as determined from the RowMapper.<P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#CONTIGUOUS_TREE_SELECTION">CONTIGUOUS_TREE_SELECTION</A></B></CODE><BR> Selection can only be contiguous.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#DISCONTIGUOUS_TREE_SELECTION">DISCONTIGUOUS_TREE_SELECTION</A></B></CODE><BR> Selection can contain any number of items that are not necessarily contiguous.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#SINGLE_TREE_SELECTION">SINGLE_TREE_SELECTION</A></B></CODE><BR> Selection can only contain one path at a time.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#addPropertyChangeListener(java.beans.PropertyChangeListener)">addPropertyChangeListener</A></B>(<A HREF="../../../java/beans/PropertyChangeListener.html">PropertyChangeListener</A> listener)</CODE><BR> Adds a PropertyChangeListener to the listener list.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#addSelectionPath(javax.swing.tree.TreePath)">addSelectionPath</A></B>(<A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A> path)</CODE><BR> Adds path to the current selection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#addSelectionPaths(javax.swing.tree.TreePath[])">addSelectionPaths</A></B>(<A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A>[] paths)</CODE><BR> Adds paths to the current selection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#addTreeSelectionListener(javax.swing.event.TreeSelectionListener)">addTreeSelectionListener</A></B>(<A HREF="../../../javax/swing/event/TreeSelectionListener.html">TreeSelectionListener</A> x)</CODE><BR> Adds x to the list of listeners that are notified each time the set of selected TreePaths changes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#clearSelection()">clearSelection</A></B>()</CODE><BR> Empties the current selection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/swing/tree/TreePath.html">TreePath</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#getLeadSelectionPath()">getLeadSelectionPath</A></B>()</CODE><BR> Returns the last path that was added.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#getLeadSelectionRow()">getLeadSelectionRow</A></B>()</CODE><BR> Returns the lead selection index.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#getMaxSelectionRow()">getMaxSelectionRow</A></B>()</CODE><BR> Returns the largest value obtained from the RowMapper for the current set of selected TreePaths.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#getMinSelectionRow()">getMinSelectionRow</A></B>()</CODE><BR> Returns the smallest value obtained from the RowMapper for the current set of selected TreePaths.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/swing/tree/RowMapper.html">RowMapper</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#getRowMapper()">getRowMapper</A></B>()</CODE><BR> Returns the RowMapper instance that is able to map a TreePath to a row.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/swing/tree/TreeSelectionModel.html#getSelectionCount()">getSelectionCount</A></B>()</CODE><BR> Returns the number of paths that are selected.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -