File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTree and indent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree and indent" Watch "JTree and indent" New topic

JTree and indent

Mika Leino
Ranch Hand

Joined: Jan 07, 2002
Posts: 56
Is there any way to modify the indent of a JTree's nodes? The practical width of my JTree is'nt very much, so I would like to display the nodes more tightly.

[ January 15, 2002: Message edited by: Mika Leino ]

Mika Leino<br />SCJP, SCWCD
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
You could try tree.setRowHeight(int) to set the height of each row.

- Vinod<br />-------<br />SCJP2
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi Mika,
Yes Mika,
You can set the tree indent for the whole application like this:

Hope that helps,
[ January 15, 2002: Message edited by: Terence Doyle ]
[ January 15, 2002: Message edited by: Terence Doyle ]

Raising Flares debut album 'Ignition' out now

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Mika Leino
Ranch Hand

Joined: Jan 07, 2002
Posts: 56
Thank you very much Terry. I got just the result I was looking for using that bit of code.
jenita brown
Ranch Hand

Joined: Feb 20, 2007
Posts: 51

My requirement is slightly different. If you notice, JTree indents the leaf nodes more then a normal node. I want to override this action and get all the children aligned, irrespective of node type.


Rob Spoor

Joined: Oct 27, 2005
Posts: 20269

Jenal, use one thread per question. You have your own thread for this question. And as Rob C said there, this post is considered a thread hijack; please don't do that anymore, ok?

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: JTree and indent
jQuery in Action, 3rd edition