KJW
KJW

Reputation: 15251

Jtree: how to hide parts of a given defaultmutabletreenode's text?

Say my JTree consists of following nodes.

new DefaultMutableTreeNode("DisplayThisTextOnly {donotdisplaystringsinhere}");

how can I hide the texts between and including {} from displaying using TreeCellRenderer?

when I select this node, I want to be able to fetch the entire string again.

"DisplayThisTextOnly {donotdisplaystringsinhere}"

Basically my goal is to be able to fetch additional data from a given tree node without having to setObject()

Upvotes: 0

Views: 988

Answers (1)

camickr
camickr

Reputation: 324197

Create a custom renderer and strip out the text you don't want to see. The section from the Swing tutorial on How to Use Trees has an example renderer to get you started.

Upvotes: 2

Related Questions