[java] Nasty repainting of my SWT windows

Started by
1 comment, last by MickeyMouse 18 years, 10 months ago
Hi everyone, I'm having a strange problems with my SWT based windows developed in Java 5.0 under Windows XP. When I'm running my SWT application and Opera at the same time, when Opera does mail check, my SWT windows with all components are completely repainted which results in nasty refreshing of the window. I get more nasty results when my application is running and screensaver is running for some time. Then, when I leave screensaver my application is repainted something like 20 times in a row, which makes my SWT application flicker for few seconds with that crazy repainting. I should add I didn't really mess with SWT repainting within my Java code. Did anybody notice the same nasty repaint thing? Or do you have an idea of what could it be? - Why my SWT window receives repaint request (I assume so) when Opera checks the mailbox? Thanks for any help with this.
Maciej Sawitus
my blog | my games
Advertisement
The OS is probably calling for the application to perform a repaint. You can disable this via "setIgnoreRepaint(false)".

If that doesn't work, then you might get things to work by writing code your "repaint(Graphics g)" method that checks whether your window has focus or not. If it doesn't have focus, have it skip the redraw.

Something like:

JFrame mainFrame = new JFrame()...public void repaint(Graphics g){   if(mainFrame.isFocusOwner())      paint(g);   else   {}  //Don't repaint!}


The key here is to figure out why "repaint" is getting called. If you figure that out, then the problem should be easilly fixed.
Thanks for your reply!

I didn't try it though because my window does have focus when it receives repaint message from OS. But repaint is surely not needed.

I also noticed that the number of repaint events my window received when coming back from screensaver is proportional to the number of Opera mail checks when being in screensaver mode. So when it's 2 hours of screensaver running I get tens of repaints afterwards. And of course, my SWT window has focus :(
Maciej Sawitus
my blog | my games

This topic is closed to new replies.

Advertisement