• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Not working JScrollPane

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
does anvbody have an idea, why my JScrollPane doesn't work? I put inside it a JTree, and there is no scrollbars when it doesn't fit.
I specify the big size of a tree:


I noticed, that when I remove the sizing commands from tree1, it takes size of 1 pixel then.
I use no layout manager, don't set the look and feel.
Any ideas?

Swing doesn't rock...
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kalet fotezu wrote:Hi,
does anvbody have an idea, why my JScrollPane doesn't work? I put inside it a JTree, and there is no scrollbars when it doesn't fit.
I specify the big size of a tree:


I noticed, that when I remove the sizing commands from tree1, it takes size of 1 pixel then.
I use no layout manager, don't set the look and feel.
Any ideas?

Swing doesn't rock...



First.. welcome kalet,

Why don't you use layout manager? So.. how you manage your panel?
Yeah, you don't have to set look and feel... that's only to customize your application to look "beautiful"
Before you say "swing doesn't rock" can you show us snipped code of yours?

Best regards,

Ramses
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kalet fotezu wrote:
does anvbody have an idea, why my JScrollPane doesn't work? I put inside it a JTree, and there is no scrollbars when it doesn't fit.



Usually you put the JTree inside a JScrollPane and not the other way round.


kalet fotezu wrote:
Swing doesn't rock...


Yes. It does.


 
kalet fotezu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I manage the layout "by hand", i calculate the positions and sizes basing on JFrame size. I know its not good solution ;)

Of course jtree goes inside scrollpane.

I think the point of the problem in my case is, that maybe the size of a jtree seen by scrollpane is 0x0 or 1x1 (thats how it is displayed when I don't mess with tree size). And even when I change the size and see the result (so i see the tree), scrollpane still thinks it is very small and doesn't show scrolbars. But why and how to change it...

I will try to prepare a working example
 
kalet fotezu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey again, here is the boxed problem.
Play with resizing the window, see how big the tree are.
Can you see where the problem is?

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You appear to be adding your JTree to the JScrollPane and not the viewport which is not how JScrollPanes work.

For instance:


Though I agree with the others in that I'd skip absolute positioning and instead would use the layout managers. For instance:
 
kalet fotezu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pete, you are a god Thank you very much!

Swing (partially) rocks
 
reply
    Bookmark Topic Watch Topic
  • New Topic