aspose file tools*
The moose likes Java in General and the fly likes Window doesn't repaint properly unitil window resized manually Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Window doesn Watch "Window doesn New topic
Author

Window doesn't repaint properly unitil window resized manually

Jeppe Larsen
Greenhorn

Joined: May 21, 2010
Posts: 8
I am using a quite basic setup with a class extending JPanel which I add to a JFrame.




What happens is, that INITIALLY the window is painted properly, but once paintComponent is called, a strip of the old image (with the same height as the toolbar panel) is visible below the newly painted images - similar to playing card sticking out from a deck. But then, if i manually resize the window by for instance dragging the border, the background is grayed out as it should.

What is going on and how do I fix this?

Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 686
    
  11
hi Jeppe,

no doubt that you see some effects of the double buffering that Swing uses.
You can fix the unwanted effects by changing the 'paintComponent()' slightly:

Greetz,
Piet
Jeppe Larsen
Greenhorn

Joined: May 21, 2010
Posts: 8
I found a solution over here http://stackoverflow.com/questions/24823336/java-window-doesnt-repaint-properly-until-i-resize-the-window-manually
 
Don't get me started about those stupid light bulbs.
 
subject: Window doesn't repaint properly unitil window resized manually