Double Buffering in Java 6

K

Knute Johnson

Jason said:
I just wanted to clarify. I noticed that improvements were made to
double buffering in Java 6 (true double buffering is now used) as
discussed here: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/.
However, I heard someone mention that double buffering is now on by
default on all components in Java 6. Is this second statement true?

No. Although it appears that you can turn it on.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class test {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JLayeredPane lp = new JLayeredPane();
System.out.println("JLayeredPane " +
lp.isDoubleBuffered());
JRootPane rp = new JRootPane();
System.out.println("JRootPane " + rp.isDoubleBuffered());
JPanel p = new JPanel();
System.out.println("JPanel " + p.isDoubleBuffered());
JButton b = new JButton();
System.out.println("JButton " + b.isDoubleBuffered());
JComboBox cb = new JComboBox();
System.out.println("JComboBox " + cb.isDoubleBuffered());
JLabel l = new JLabel();
System.out.println("JLabel " + l.isDoubleBuffered());
JInternalFrame f = new JInternalFrame();
System.out.println("JInternalFrame " +
f.isDoubleBuffered());
JScrollPane sp = new JScrollPane();
System.out.println("JScrollPane " + sp.isDoubleBuffered());
Box bx = new Box(0);
System.out.println("Box " + bx.isDoubleBuffered());
JTextArea ta = new JTextArea();
System.out.println("JTextArea " + ta.isDoubleBuffered());

Canvas c = new Canvas();
System.out.println("Canvas " + c.isDoubleBuffered());

b.setDoubleBuffered(true);
System.out.println("\nJButton " + b.isDoubleBuffered());
cb.setDoubleBuffered(true);
System.out.println("JComboBox " + cb.isDoubleBuffered());
sp.setDoubleBuffered(true);
System.out.println("JScrollPane " + sp.isDoubleBuffered());
ta.setDoubleBuffered(true);
System.out.println("JTextArea " + ta.isDoubleBuffered());
}
});
}
}

C:\Documents and Settings\Knute Johnson>java test
JLayeredPane false
JRootPane true
JPanel true
JButton false
JComboBox false
JLabel false
JInternalFrame false
JScrollPane false
Box false
JTextArea false
Canvas false

JButton true
JComboBox true
JScrollPane true
JTextArea true
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top