Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

scrolling: adjusting a JTree inside JScrollPane inside a JSplitPane  RSS feed

 
keddy lewis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To whom may a solution be found,

I have placed a component inside and which inturn is on the Left side of a (pretty eh!).

The tree structure continously grows and shrinks depending on the infomation the user requires.

The problem is the scrolls bar will only show if you of the JTree manually.
This would be fine, however, i have no way of working out WHAT THE SIZE OF THE should be to show all the nodes in it.

One 'not' nice solution is to really big !! and have a really large JTree which is mostly blank space and has scrollbars which do not reflect the JTree's data at all but it does work !! It must be possible to workout the best size to set the JTree to (ie how many visible rows are there).
If you have any idea please let me know.

Regards, smile and thank you

Keddy
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works OK in this
(expand any of the nodes to see the scrollbar)



can you post a sample program (similar to above) that demonstrates the problem
 
keddy lewis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn,

Your code works fine ... i know ! However the content is not be changed dynamically at runtime (and hence the Scrollpane would then need to adjust itself to handle a larger number of sibling nodes)!

This i believe is the issue.. i may have not made myself clear ...sorry.

It is not the scrollbar functionality that seems to be the issue it is the percieved size (or the resizing ) of the JTree in the JScrollpane.

I hope i am correct and have expressed myself clearly enough

Thank you for your support and help..

..alittle more would no go a miss !!

Regards

Keddy Lewis
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see if this is closer to your description - but it still works OK

 
Scott Flinn
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realize this is a bit late, but I'll add a comment in case anyone else stumbles across this looking for an answer.

I had the same container arrangement described by Keddy, and the same problem. By comparing to Michael's sample code, I found the problem -- in my case at least.

I was using code generated by NetBeans 6.8 which had set an explicit preferred size for my JTree. I was able to fix the problem by invoking



immediately following the call to the NetBeans-generated initComponents method to allow the UI to manage its own preferred size.
 
John Slocum
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having an issue which would qualify under the title of this post, although the issue is slightly different. My startup routine sets the look-and-feel to native if possible. In windows, when I add the tree to the scrollpane, the tree is aligned right up against the top and left of the pane, which is visually jarring. I can't for the life of me figure out how to position the tree within the pane, giving it a little padding to the pane, so the tree sits a little to the right of the pane's left edge, looking more standard in windows, like eclipse or outlook trees. Any suggestions?
 
Stephan van Hulst
Saloon Keeper
Posts: 6980
110
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try adding an EmptyBorder to your JTree.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!