JavaTM Platform
Standard Ed. 6

javax.swing.tree
インタフェース TreeCellRenderer

既知の実装クラスの一覧:
DefaultTreeCellRenderer

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 に設定します。
 

メソッドの詳細

getTreeCellRendererComponent

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 であれば、ノードに現在フォーカスがあります。treeJTree の場合、レシーバは設定中です。レンダリングが値を描画するのに使う Component を返します。

ツリーの現在のドラッグ&ドロップ位置を示すセルがあれば、TableCellRenderer もこのセルを描画するために使用されます。このレンダリングがドラッグ&ドロップ位置の描画を考慮する場合、ツリーを直接照会して、指定の行がドロップ位置を表しているかどうかを確認することになっています。

     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

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。