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

JFrame repaint flickering on Windows 7

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 6u16
    • client-libs

      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 ----------

            alexp Alexander Potochkin (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: