Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame is flickering while resizing.....

 
Manoj Amrutkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Manoj
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have this line in your code
JFrame.setDefaultLookAndFeelDecorated(true);

add this line
System.setProperty("sun.awt.noerasebackground", "true");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic