File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JScrollPane and hidden content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane and hidden content" Watch "JScrollPane and hidden content" New topic
Author

JScrollPane and hidden content

Michele Palmia
Greenhorn

Joined: Nov 11, 2009
Posts: 4
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

Joined: Feb 23, 2007
Posts: 1561
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

Joined: Nov 11, 2009
Posts: 4
thank you for the answer!
this is what I've done, hope you can help me!


Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Michele Palmia
Greenhorn

Joined: Nov 11, 2009
Posts: 4
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!

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JScrollPane and hidden content
 
Similar Threads
JList inside a Fixed width JScrollPane
setting focus to a tab in a JTabbedPane
Issues with graphics being repainted/updated
JScrollPane, JPanel & Scale mehtod.... not working
Resizing of a Component freezes the screen and contents of JTable are greyed