CheckboxTree not Displaying Node Names

Answered

I am currently trying to add a tree with check-boxes to a dialog. I have successfully added the tree and its nodes; however, when I look at it the node names are not displaying. Below is how I initialize the tree, I also have an image attached of how it looks like. How do I get it to display the names?

codeFileTree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer() {},
new CheckedTreeNode("bob"),
new CheckboxTreeBase.CheckPolicy(true, true, false, false));

2 comments
Comment actions Permalink

CheckboxTreeCellRenderer is an abstract class for a reason.
You should override `customizeRenderer` method to render the rest of the node:

new CheckboxTree.CheckboxTreeCellRenderer() {
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof MyTreeNode) {
getTextRenderer().setIcon(...);
getTextRenderer().append(...);
}
}
}
1
Comment actions Permalink

Thank you for the swift reply. It resolved my issue.

0

Please sign in to leave a comment.