Modification of a SWING tree node label

  • Thread starter MARTIN Herve \(EXT\)
  • Start date
M

MARTIN Herve \(EXT\)

Hi,
I want to modify the label of a DefaultMutableTreeNode.
So I change the value returned by the method toString() of the node's user
object, and make the tree be repainted.

However if the label becomes longer that the original value,
the new label is displayed truncated, ended with '...'.

How can I get the complete label display?
Note: I don't want to create a new node with the new label, to replace the
existing node.

Hervé.
 
I

Ike

Hello Martin,

I went and looked at some code I did where I put long leafs of text on a
jtree. I didn't enoucnter the problem you speak of here, BUT, I DID put the
JTree on a ScrollPane. -Ike
 
C

Chris Smith

MARTIN Herve \(EXT\) said:
Hi,
I want to modify the label of a DefaultMutableTreeNode.
So I change the value returned by the method toString() of the node's user
object, and make the tree be repainted.

However if the label becomes longer that the original value,
the new label is displayed truncated, ended with '...'.

How can I get the complete label display?
Note: I don't want to create a new node with the new label, to replace the
existing node.

I don't see this problem. One question though: are you just repainting,
or are you firing an appropriate TreeModelEvent. If the former, then
forget repainting and fire a TreeNodeEvent instead, dispatching it to
treeNodesChanged in the listeners. If you're using DefaultTreeModel,
then use the nodeChanged(TreeNode) method to do this.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
M

MARTIN Herve \(EXT\)

ok, thanks Chris,
a call to nodeChanged() fixes my display problem

Hervé.
 
M

MARTIN Herve \(EXT\)

Hi,

Talking about long leaves of text, did you create leaves with a text on
several lines or just a very long one-line text?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top