I want to expand my Jtree nodes into multiple lines. Any idea for how to achieve this?

Ya I already had a look there, but the example is looking bit complex for me to understand so looking for a solution in simple words, I do not want any working code to do this just want to know the process to make this happen.

I vote your answer as best reply in April 2011, but here isn't "lonely hearts" post your code, then we'll see

I've never tried this, but the nodes in JTree are rendered by default using JLabels.
You can put multi-line text in a JLabel by using simple HTML, so maybe you can use HTML to get multi-line nodes? Try a node with text like this:
<HTML>line 1a<BR>line1b<?HTML>
you never know...

Just tried it - it works.

I've never tried this, but the nodes in JTree are rendered by default using JLabels.
You can put multi-line text in a JLabel by using simple HTML, so maybe you can use HTML to get multi-line nodes? Try a node with text like this:
<HTML>line 1a<BR>line1b<?HTML>
you never know...

Just tried it - it works.

Yeah it is working fine. But still one problem is there.
In default look and feel of java swing it is working fine, as it automatically expand the node height

but when we switch to Windows look and feel it fails, as in that mode it do not expand the height, i was facing this problem from the morning as i'm working in windows look and feel, so failed to figure out what was going wrong.

Have any idea, how to make it work even in windows look and feel?

Sorry, that's not something I've tried. I guess you'll just have to keep experimenting, unless anyone else has a better idea...?

no, not, you have to search how to expand Node or ... programatically, nothing else, link that I posted contains example for that

to L&F --> with same result as JamesCherrill, because each L&F allways depends by Native OS runs on, sure there exist something as BasicTreeUI, MetalTreeUi ..., but againg depends by Native OS and L&F too, and Over Ride these methods are (to hard) nuts for teams of Swing Gurus


and here too http://www.exampledepot.com/egs/javax.swing.tree/pkg.html

no, not, you have to search how to expand Node or ... programatically, nothing else, link that I posted contains example for that

to L&F --> with same result as JamesCherrill, because each L&F allways depends by Native OS runs on, sure there exist something as BasicTreeUI, MetalTreeUi ..., but againg depends by Native OS and L&F too, and Over Ride these methods are (to hard) nuts for teams of Swing Gurus


and here too http://www.exampledepot.com/egs/javax.swing.tree/pkg.html

yeah, i am experimenting with TreeRenderer, hoping to get it done for windows L&F as well. Otherwise I will certainly need to find another way around. Anyways, thanks you gave me some bit of ideas to work on.

Please let us know how you get on - especially if you find a way to get it under Win L&F
J

Please tell us exactly what it was you had to do with rowHeight
thanks
J

Please tell us exactly what it was you had to do with rowHeight
thanks
J

In windows LAF row height is default set to around 15 or 18, so now I just increased the row height of my Jtree to say jTree.setRowHeight(28) depending upon how many rows I want to show in my nodes.

OK, thanks
cheers
J

I must "be quite" again, but then I 2nd. times *** you,

majorities of Forums required be forgive on Crossposting,

you can crosspost your question how many times as you wants, but you have to add link to another Forum(s) to your question, its Saturday and so ...

I must "be quite" again, but then I 2nd. times *** you,

majorities of Forums required be forgive on Crossposting,

you can crosspost your question how many times as you wants, but you have to add link to another Forum(s) to your question, its Saturday and so ...

This is nice of you, i'm new to forums so not much aware of rules and traditions here, I will keep good care of it in future. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.