uTools-Manuals/docs/java/javax/swing/tree/TreeCellRenderer.html

101 lines
5.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="header">
<div class="subTitle">
javax.swing.tree
</div>
<h2 class="title" title="Interface TreeCellRenderer">Interface TreeCellRenderer</h2>
</div><div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>
所有已知实现类:
</dt>
<dd>
<span><a href="../../../javax/swing/tree/DefaultTreeCellRenderer.html" title="javax.swing.tree中的类">DefaultTreeCellRenderer</a></span>
</dd>
</dl>
<hr/> <br/> <pre>public interface <span class="typeNameLabel">TreeCellRenderer</span></pre>
<div class="block">
<span>定义显示树节点的对象的要求。</span>
<span>有关<a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">实现</a>显示自定义图标的树状单元格渲染器的示例,请参阅<em>Java教程</em>中的How to Use Trees。</span>
</div> </li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- --> </a> <h3>方法摘要</h3>
<table border="0" cellpadding="3" cellspacing="0" class="memberSummary" summary="Method Summary table, listing methods, and an explanation">
<caption>
<span class="activeTableTab" id="t0"><span>所有方法</span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t2"><span><a href="javascript:show(2);">接口方法</a></span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t3"><span><a href="javascript:show(4);">抽象方法</a></span><span class="tabEnd"> </span></span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor" id="i0">
<td class="colFirst"><code><a href="../../../java/awt/Component.html" title="class in java.awt">Component</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../javax/swing/tree/TreeCellRenderer.html#getTreeCellRendererComponent-javax.swing.JTree-java.lang.Object-boolean-boolean-boolean-int-boolean-">getTreeCellRendererComponent</a></span>(<a href="../../../javax/swing/JTree.html" title="class in javax.swing">JTree</a> tree, <a href="../../../java/lang/Object.html" title="class in java.lang">Object</a> value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)</code>
<div class="block">
将当前树状单元格的值设置为
<code>value</code>
</div> </td>
</tr>
</tbody>
</table> </li>
</ul> </li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- --> </a> <h3>方法详细信息</h3> <a name="getTreeCellRendererComponent-javax.swing.JTree-java.lang.Object-boolean-boolean-boolean-int-boolean-">
<!-- --> </a>
<ul class="blockListLast">
<li class="blockList"> <h4>getTreeCellRendererComponent</h4> <pre><a href="../../../java/awt/Component.html" title="class in java.awt">Component</a> getTreeCellRendererComponent(<a href="../../../javax/swing/JTree.html" title="class in javax.swing">JTree</a> tree,
<a href="../../../java/lang/Object.html" title="class in java.lang">Object</a> value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)</pre>
<div class="block">
<span>将当前树状单元格的值设置为<code>value</code></span>
<span>如果<code>selected</code>为真,则将像选择一样绘制单元格。</span>
<span>如果<code>expanded</code>为真,则节点当前被扩展,并且如果<code>leaf</code>为真,则节点表示叶,并且如果<code>hasFocus</code>为真,则节点当前具有焦点。</span>
<span><code>tree</code><code>JTree</code>所述接收器被构造成用于。</span>
<span>返回渲染器用来绘制值的<code>Component</code></span>
<p> <span><code>TreeCellRenderer</code>还负责渲染表示树的当前DnD丢弃位置的单元格如果它有一个。</span> <span>如果这个渲染器关心渲染DnD放置位置它应该直接查询树看看给定的行是否代表放置位置</span> </p>
<pre> <span>JTree.DropLocation dropLocation = tree.getDropLocation();
if (dropLocation != null
&amp;&amp; dropLocation.getChildIndex() == -1
&amp;&amp; tree.getRowForPath(dropLocation.getPath()) == row) {
// this row represents the current drop location
// so render it specially, perhaps with a different color
}</span> </pre>
</div>
<dl>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
渲染器用来绘制值的
<code>Component</code>
</dd>
</dl> </li>
</ul> </li>
</ul> </li>
</ul>
</div>
</div>