Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Swing, Is there a way to temporarily freeze repainting of a JComponent containment hierarchy?

If I have a bunch of custom JComponents in a Swing panel, and each of them can contain many other JComponents, is there a way to "freeze" repaints on the top level components and then unfreeze them, triggering a repaint?

I guess I am trying to do sort of a localized double-buffering.

like image 337
Uri Avatar asked Oct 14 '22 13:10

Uri


1 Answers

Also, just in case the reason you're doing this is because you are doing a bunch of GUI updates to components and are worrying about all of those automatically posted repaints(), don't. repaint() does not paint immediately, it posts a deferred repaint event to the AWT event queue, which will coalesce multiple repaints for a given region to avoid doing the same painting over and over.

like image 120
CarlG Avatar answered Oct 18 '22 13:10

CarlG