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

Unnecessary painting in Swing during startup and window resizing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 1.4.1, 1.4.2, 5.0
    • client-libs
    • b28
    • x86
    • linux, linux_redhat_9.0

      Run the following test case and notice that when the app is brought up
      the panel is painted twice.

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

      public class Test {
          public static void main(String[] args) throws Throwable {
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      show();
                  }
              });
          }

          private static void show() {
              JFrame frame = new JFrame("TEST");
              JComponent button = new JPanel() {
                  public void paint(Graphics g) {
                      super.paint(g);
                      System.out.println("----------PAINTING---------------------");
                      System.out.println("widget bounds: " + getBounds());
                      System.out.println("clip: " + g.getClip());
                  }
              };
              frame.setLayout(new FlowLayout());
              frame.add(button);
              frame.pack();
              frame.show();
          }
      }

            svioletsunw Scott Violet (Inactive)
            svioletsunw Scott Violet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: