Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane and hidden content

 
Michele Palmia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
My JScrollPane works properly with scrollbars etc., but I have a big problem.
When the initial viewPoint is created, everything is ok, but if I scroll down, I would expect to see the hidden contents (I have a long list o JPanels with FlowLayout on Y-Axis) but... nothing is shown!
To view the "new" contents, I have to resize my window... and it's not very smart.
How can I solve this? It doesn't seem to be a particular problem of my PC or my OS because examples (java applets) on the Sun page are ok!

thank you
mic
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michele Palmia wrote:Hi!
My JScrollPane works properly with scrollbars etc., but I have a big problem.
When the initial viewPoint is created, everything is ok, but if I scroll down, I would expect to see the hidden contents (I have a long list o JPanels with FlowLayout on Y-Axis) but... nothing is shown!
To view the "new" contents, I have to resize my window... and it's not very smart.


My guess is that it's a layout issue, and in particular, the layout of the component that is held by the scrollpane's viewport. If it uses FlowLayout, please understand that FlowLayout is not particularily "intelligent" as some of the other layout managers.

For more help, you may wish to create and post a small demo program that we can run and that shows your problem.

Much luck!
 
Michele Palmia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the answer!
this is what I've done, hope you can help me!


 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I test ran your code and I don't see the problem you stated. I do see other problems with the code, namely that youare mixing AWT and Swing components in the same GUI. Don't do this. I recommend changing over totally to Swing components.

Then too, the Swing components should be constructed and launched on the EDT. Read this for details:
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html

I've refactored your code to incorporate my advice, and also shortened it by getting rid of various things not relevant to your problem.

 
Michele Palmia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey!
thank you for the advices and for the code. The problem I described is solved with your new setup!
It was very useful to see a well coded but simple Dialog. thank you!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic