CheckboxTree not Displaying Node Names


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));

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() {
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof MyTreeNode) {
Comment actions Permalink

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


Please sign in to leave a comment.