public interface TreeCellRenderer
| 修飾子と型 | メソッド | 説明 |
|---|---|---|
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もこのセルを描画するために使用されます。 このレンダリングがドラッグ&ドロップ位置の描画を考慮する場合、ツリーを直接照会して、指定の行がドロップ位置を表しているかどうかを確認することになっています。
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 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。