jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes JFrame is flickering while resizing..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame is flickering while resizing....." Watch "JFrame is flickering while resizing....." New topic

JFrame is flickering while resizing.....

Manoj Amrutkar
Ranch Hand

Joined: Apr 15, 2006
Posts: 47
Mine application has a JFame application window having JDesktopPane in it for JInternalFrame.
Now the problem i am facing is when i resize my application window in restore mode, by dragging the mouse. I am getting flickering images of the window. It's very irritating. So if any body has any type of solution on this plz reply.

thanks in advance

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
I have had rather similar problems before, but with a different sort of app.
The Java tutorial has a "common problems" page, so I looked there. I tried things to speed up processing, as suggested in the tutorial, including changing all my doubles to floats.
I tried opacifying the content pane, but still had problems.
I tracked it down to a method which was applying an affine transform to the Graphics2D object. Without the transform the method took 1.6 microseconds to run, with, it was much slower, over 50 microseconds, but the same method run a 2nd time was faster, about 8 microseconds.
That delay was obviously what caused my problems.

Eventually I sorted it out by setting up a Timer to repaint() the whole things repeatedly. A cheat's workaround maybe, but it worked.

Have you got anything like that? Go through all your methods with the System.nanoTime() method and see if you can find such a delay.
Put System.out.print() calls into every method, and follow their sequence. Have you got any loops where your control is recirculating?
When you drag your window, does it remain visible? Have you tried that method which turns your window into an outline when you drag it?

That's all I can suggest. Maybe somebody else will have a better idea.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you have this line in your code

add this line
System.setProperty("sun.awt.noerasebackground", "true");
I agree. Here's the link: http://aspose.com/file-tools
subject: JFrame is flickering while resizing.....
jQuery in Action, 3rd edition