How to adjust a JScrollPane to its contained JTree
- by spuas
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