Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Window doesn't repaint properly unitil window resized manually

 
Jeppe Larsen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1152
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic