How to adjust a JScrollPane to its contained JTree
Posted
by
spuas
on Stack Overflow
See other posts from Stack Overflow
or by spuas
Published on 2010-12-28T15:14:55Z
Indexed on
2010/12/28
15:54 UTC
Read the original article
Hit count: 247
Hello, here I have a swing size question:
I have a JTree
which is contained inside a JScrollPane
(which is contained in a custom component which extends JXPanel from swingx, but I think that has nothing to do with this question).
Doesn't matter how many rows the tree has, the scrollpane is always bigger (the tree is dinamic but not designed to have many rows) but what I would like is the JScrollPane to adjust to the tree initial height and then show the vertical scroll when some of the nodes are expanded.
I have tried without setting any size at all, setting tree preferred size to null
and setting scrollpane preferred size to null
as well but nothing changes. I DO NOT WANT to set the size manually... Is there a way to do this?
Thanks
© Stack Overflow or respective owner