public class JTextPaneTreeCellRenderer extends JTextPane implements TreeCellRenderer {
Method:
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
setEditable(selected);
setText(value.toString());
if (leaf)
setBackgroundColor(Color.RED);
return this;
}
You do not need to be as complicated as the default implementation. Subclassing Renedere under JTextPanewill facilitate the implementation of the method.
source
share