|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface TreeCellRenderer
定义针对显示树节点的对象的要求。有关实现显示自定义图标的树单元格渲染器的示例,请参阅 The Java Tutorial 中的 How to Use Trees 一节。
| 方法摘要 | |
|---|---|
Component |
getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
将当前树单元格的值设置为 value。 |
| 方法详细信息 |
|---|
Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
value。如果 selected 为 true,则将单元格作为已选择的单元格进行绘制。如果 expanded 为 true,则当前扩展该节点,如果 leaf 为 true,则该节点表示叶节点,如果 hasFocus 为 true,则该节点当前拥有焦点。tree 是为其配置接收者的 JTree。返回渲染器用来绘制值的 Component。
TreeCellRenderer 也负责呈现表示树当前 DnD 放置位置的单元格(如果有)。如果此渲染器关心呈现 DnD 放置位置,则它应该直接查询该树以查看给定行是否表示放置位置:
JTree.DropLocation dropLocation = tree.getDropLocation();
if (dropLocation != null
&& dropLocation.getChildIndex() == -1
&& tree.getRowForPath(dropLocation.getPath()) == row) {
// this row represents the current drop location
// so render it specially, perhaps with a different color
}
Component
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。