Dynamically updating size of a scrollable JTree so that contents can always be completely scrolled through.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Axelle_Apvrille
Posted On:   Tuesday, October 2, 2001 03:07 AM

I have put a JTree in a JScrollPane. I have set the preferred size of my JTree (defining actually the size of the virtual possible view) and the preferred size of the scroll pane (defining the size which is actually seen). The problem is the contents of my JTree change and may increase or decrease in length. If the contents of my JTree exceed the initial dimension I set for my JTree, I cannot scroll past that dimension. I'd like to build a scrollable JTree in which I can always scroll through all content. I.e. the scrolls must shrink or increase depending the contents are big or small. It is seems this is automatical for JTextArea's in JScrollPanes, but not JTree. How can I do this ? Thanks, Axe   More>>

I have put a JTree in a JScrollPane.
I have set the preferred size of my JTree (defining actually the size of the virtual possible view)
and the preferred size of the scroll pane (defining the size which is actually seen).

The problem is the contents of my JTree change and may increase or decrease in length. If the contents of my JTree exceed the initial dimension I set for my JTree, I cannot scroll past that dimension.
I'd like to build a scrollable JTree in which I can always scroll through all content. I.e. the scrolls must shrink or increase depending the contents are big or small.

It is seems this is automatical for JTextArea's in JScrollPanes, but not JTree. How can I do this ?

Thanks,
Axelle.

			
treeResult.setPreferredSize(new Dimension(3000,3000));
...
JScrollPane scroll = new JScrollPane(treeResult);
scroll.setPreferredSize(new Dimension(700,200));
   <<Less

Re: Dynamically updating size of a scrollable JTree so that contents can always be completely scrolled through.

Posted By:   Prashanth_Godey  
Posted On:   Tuesday, October 2, 2001 11:49 AM

try without setting any dimension to the tree........ It should scroll automatically since it is wrapped in the scrollpane.....
About | Sitemap | Contact