|
JavaTM 2 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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。