What is Double-buffering in Java?
- Double-buffering is the process of drawing graphics into an off-screen image buffer and then copying the contents of the buffer to the screen all at once.
- For the complex graphics, using double-buffering can reduce flickering issues.
- Java Swing automatically supports double-buffering for all of its components.
- Double-buffering is memory intensive, its use is only justified for components that are repainted very frequently or have particularly complex graphics to display.
- If a container uses double-buffering, any double-buffered children it has shared the off-screen buffer of the container, the required off-screen buffer is never larger than the on-screen size of the application.
- To enable double buffering, simply call the setDoubleBuffered() method (inherited from JComponent) to set the double-buffered property to true for any components that should use double-buffered drawing.
Updated on 30-Jul-2019 22:30:26