• Post Reply Bookmark Topic Watch Topic
  • New Topic

ImagePanel gets corrupted when scrolled.  RSS feed

 
Tom Hughes
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I've created a little ImageViewer applet. I use simple ImagePanels that overide paintComponent and paints a picture. This works fine, except when I put it in a scroll pane. When the image scrolls, the image gets corrupted. I'm not 100% sure what is happening, I figure I need to call paint, repaint or revalidate at some point but not exactly sure.
An example is here
Please help !
thanks,
Tom
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found that when my components don't paint properly it is because I forgot to call super.paintComponent(g);. Of course, it could be something else, but that's all I can suggest off the top of my head.
HTH
Layne
 
Tom Hughes
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the suggestion, but I do that already.
Tom
 
Tom Hughes
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bump! Help !
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the example link is the applet you're having trouble with... ummm... it actually works for me... Using JDK 1.4.1_01 on Windows 2K, using the Java Plugin in IE 6.
 
Tom Hughes
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Nate. You know I've tried it at work and now it works for me too. Must be something wrong with my setup at home.
I notice that the image still gets corrupted when the applet scrolls on and off the web page (e.g. when I make my browser window real small & scroll around). It kind of rights itself when you click on where the applet should be. Is there a cure for this ?
thanks,
Tom
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've noticed that too in other components... if you move them around the screen really fast they will get corrupted where the edges of the desktop clip them off. I'm not sure if there is a good fix for this... you may want to try a background thread that periodically repaints the entire applet... it shouldn't be too big of a performance hit.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!