Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4062021

JPanel with no double buffer draws its components without erasing behind screen.

XMLWordPrintable

    • b01
    • sparc
    • solaris_2.5.1
    • Not verified

        JPanel that has no double buffering draws its components without cleaning previous screen. As a result of that, components from different JPanel can be seen at the same time.

        To reproduce the problem, run the following test app.
        The first tab has double-buffering panel while the second has non double buffering panel.
        Test Procedure:
        click first tab and second tab.

        // Test app
        import java.awt.*;
        import java.awt.event.*;
        import com.sun.java.swing.*;

        public class Test extends JFrame{
            JScrollPane sp1, sp2;
            JPanel onePanel;
            JPanel otherPanel;
            JTabbedPane tp;

            // if the container panel has double-buffering, it works fine no matter what
            // children panels has double or non double buffering to draw their
            // components.
            public static JPanel bodyP = new JPanel(); // true

            public Test() {
                super("test");

                bodyP.setLayout(new BorderLayout());

                onePanel = new JPanel(true);
                onePanel.setLayout(new BoxLayout(onePanel, BoxLayout.X_AXIS));
                onePanel.add(new JButton("one"));

                otherPanel = new JPanel(false);
                otherPanel.add(new JButton("two"));

                tp = new JTabbedPane();
                tp.addTab("test-tab1", null, onePanel);
                tp.addTab("test-tab2", null, otherPanel);
                tp.setSelectedIndex(0);

                bodyP.add("Center",tp);

            }

            public static void main(String args[]) {
                WindowListener wl = new WindowAdapter(){
                    public void windowClosing(WindowEvent event){
                        System.exit(0);
                    }
                };
                Test frame = new Test();
        frame.setBackground(Color.lightGray);
        frame.addWindowListener(wl);
        frame.setSize(500,200);
        frame.add("Center", bodyP);
                frame.show();
            }
        }

        // end of file.

              jeff Jeff Dinkins
              bkimsunw Bae-chul Kim (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: