This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JScrollPane and hidden content

 
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
 
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!


 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • 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!

 
Look ma! I'm selling my stuff!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic