Java Swing AWT Question:
Download Questions PDF

What is the use of double buffering in swings?

Swing AWT Interview Question
Swing AWT Interview Question

Answer:

Double buffering can be achieved by using the Jcomponent class that allows the Swing component to enable this feature. Double buffering allows the component to execute faster or take less time to render the individual parts of the screen. It allows the component to be drawn and doesn't refresh it all the times. The refreshes done, in the background for the processes that requires the dynamic content to be displayed. Due to this, the flickering of the component gets reduced and the component appears to be smooth. The screen updates the monitor at very high speed so that the component appears to perform well. Copies of the component within the area are faster and the rendering can be performed at higher speed by knowing the position of the component. The program that can be used to activate the buffering is:

boolean doubleBuffered property of JComponent. Passing in true to the
setDoubleBuffered()
// This is the method that enables the double buffering for the component. It holds two values true or false
JButton button = new JButton("test");
button.setDoubleBuffered(true);
// The value true is used to turn on double buffering

Download Swing AWT Interview Questions And Answers PDF

Previous QuestionNext Question
What is the purpose of Serialization in Swings?What is the use of JComponent Class in Swing?