# [java] Nasty repainting of my SWT windows

This topic is 4808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites

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 :(

1. 1
2. 2
3. 3
4. 4
frob
13
5. 5

• 16
• 13
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632170
• Total Posts
3004550

×