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

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

I think I'm trying to do some kind of localized double buffering.

+5
source share
2 answers

Also, just in case, the reason you do this is because you are doing a bunch of GUI updates for components and worried about all these automatically placed repaints (), don't do this. repaint () does not show off immediately; it sends a delayed redraw event to the AWT event queue, which combines several repressions for a given region to avoid repeating the same picture over and over again.

+3
source

Overriding paint(Graphics)to do nothing if the flag is set will prevent the picture from appearing; You can also add your own double buffering by overriding drawing on the image.

JComponent swing, setDoubleBuffered(boolean), , , .


, , , ; ( ).

+1

All Articles