File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JScrollPane and Canvas problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply locked New topic

JScrollPane and Canvas problem

Amit Rosner

Joined: Dec 03, 2001
Posts: 22
I have a panel, whose layout is GridLayout, that contains Canvas Objects, each in its own new JPanel. All of the canvas objects are lined in one column, using the GridLayout. New canvas objects can be added dynamically to the panel, at the bottom.
Now, this panel is contained in a JScrollPane. As long as there is no need for the scrollbars to appear, i.e. all of the canvas object can be shown together, there is no problem.
But, when scroll is needed, the region of the canvas that need not to be shown until scrolled to it is still visible.
I mean: the scroll works ok, I can scroll both horizontally and vertically, but all of the canvas objects that need to be hidden at the bottom (and their rightmost regions) are visible, overriding other components below the scrollpane, and the scrollpane's vertical scrollbar.
How can I fix it, so that whenever I scroll, all of the unnecessary drawing will be hidden until scrolled to?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Already answered in this thread... so I'm closing this one...


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: JScrollPane and Canvas problem
It's not a secret anymore!