JDK-6898838 : JFrame repaint flickering on Windows 7
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u16
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_7
  • CPU: x86
  • Submitted: 2009-11-06
  • Updated: 2011-02-16
  • Resolved: 2011-02-07
Description
FULL PRODUCT VERSION :
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

Also happens with 32-Bit version.

ADDITIONAL OS VERSION INFORMATION :
64bit Windows 7
32bit Windows 7

EXTRA RELEVANT SYSTEM CONFIGURATION :
Windows 7 Ultimate 64bit
NVIDIA Geforce 8800GT
Intel Core 2 Duo CPU E8400 @ 3.00GHz
Asus P5K motherboard
4 gigabytes of ram

A DESCRIPTION OF THE PROBLEM :
Any JFrame that makes use of JFrame.setDefaultLookAndFeelDecorated(true);
that is resized will flicker a black background while repainting once the process
memory reaches around 65mb (on my machine). Of course the average swing desktop
applications start up with around or over 65mb of memory, the example ofcourse will only begin to flicker on my machine after resizing randomly for about a minute... (once reaching 65mb)

If JFrame.setDefaultLookAndFeelDecorated(true); is not used, JFrames have a horribly slow repaint on Windows 7, causing a delay on every resize, luckily JFrame.setDefaultLookAndFeelDecorated(true);
solves this delay, but after accumulating a certain amount of memory it ofcourse flickers horribly.

The application continues to function perfectly and respond quickly, even with the flicker.
This can be seen with Metal Look&Feel, or any other as long as JFrame.setDefaultLookAndFeelDecorated(true);
is used.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Swing application with a JFrame using JFrame.setDefaultLookAndFeelDecorated(true); and run on a Windows 7 system. The flickering will occur once enough memory has been allocated. (approx 65mb on my machine - see my specs in configuration information)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No flickering should occur.
ACTUAL -
JFrame and its contents flicker wildly on resizing with the mouse.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package testapp;

import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

/**
 *
 * @author Dax Frost
 */
public class Main extends JFrame {

    public Main() {
        super("spooge");

        // button added for easier flicker visiblity
        add(new JButton("button"));
        setIgnoreRepaint(true);

        setSize(200, 200);
        setVisible(true);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {

                try {
                    Toolkit.getDefaultToolkit().setDynamicLayout(true);
                    JFrame.setDefaultLookAndFeelDecorated(true);
                    System.setProperty("sun.awt.noerasebackground", "true");
                } catch (Exception e) {
                    e.printStackTrace();
                }

                new Main();
            }
        });

    }
}

---------- END SOURCE ----------

Comments
EVALUATION not enough data - closed
07-02-2011

PUBLIC COMMENTS I used Microsoft Windows [Version 6.1.7600] and java version "1.6.0_16" Java(TM) SE Runtime Environment (build 1.6.0_16-b01) Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode) and I can't reproduce the bug. Your test took only 17 Mb and memory usage didn't grow more while frame resizing.
12-08-2010