Hello!
I have implemented a class which extends JPanel in which I've
overridden PaintComponent() to visualize a tree (or graph) using the
Graphics2D package. I've put this into a jScrollPane, because the
tree is typically bigger than the screen will allow. The graphics
work nicely, but once the panel is scrolled, it "chops up" the image
(on the part that was originally not shown.)
I was wondering if anyone knew of a simple (or not simple, but simple
is preferable, obviously) way to fix this problem.
Thanks for your help!
-Adam
A. Bolmarcich - 27 Mar 2007 20:40 GMT
> Hello!
>
[quoted text clipped - 9 lines]
>
> Thanks for your help!
As an initial experiment, invoke
getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE)
on the JScrollPane. If that eliminates the "chopping up" of the portion
of the JPanel exposed by scrolling, and you are not concerned about
scrolling performance, then you are done.
Adam Polt - 27 Mar 2007 22:11 GMT
On Mar 27, 2:40 pm, "A. Bolmarcich" <agge...@earl-grey.cloud9.net>
wrote:
> > Hello!
>
[quoted text clipped - 17 lines]
> of the JPanel exposed by scrolling, and you are not concerned about
> scrolling performance, then you are done.
This seems to fix the problem. Thank you very much!
-Adam
Daniel Pitts - 27 Mar 2007 21:32 GMT
> Hello!
>
[quoted text clipped - 11 lines]
>
> -Adam
It very well could be that you are rendering from the wrong thread.
Make sure you are following the single-thread-access idiom used in
Swing.