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

Modal JDialog fails to repaint properly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • 2d
    • beta3
    • x86
    • generic, windows_nt
    • Verified



      Name: bsC130419 Date: 05/31/2001


      DELL_44_GREGL:gleichtm@/cygdrive/e> java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
      DELL_44_GREGL:gleichtm@/cygdrive/e>

      Modal JDialog's are not repainted properly when dragged off and then back on
      screen or when other windows are dragged across it slowly. Source code to
      generate the problem is included below:

      ------------------------- File Application1.java

      package dialogrenderingbugjdk1_4;

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

      /**
       * Rendering bug. Drag frame off right or bottom of screen, then slowly drag
       * frame back on screen. Multiple unrendered blocks remain. See Frame1
       * class for comment on how to improve but not totally eliminate problem.
       *
       * This application can be run with:
       *
       * java -cp . dialogrenderingbugjdk1_4.Application1
       *
       * when in the directory just above dialogrenderingbugjdk1_4.
       *
       * Gregg Leichtman, Ph.D.
       * ###@###.###
       */
      public class Application1 {
        boolean packFrame = false;

        /**Construct the application*/
        public Application1() {
          Frame1 frame = new Frame1();
        }

        /**Main method*/
        public static void main(String[] args) {
          try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          }
          catch(Exception e) {
            e.printStackTrace();
          }
          new Application1();
        }
      }

      ------------------------- File Frame1.java

      package dialogrenderingbugjdk1_4;

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

      public class Frame1 extends JFrame {
        JPanel contentPane;
        BorderLayout borderLayout1 = new BorderLayout();
        JScrollPane jScrollPane1 = new JScrollPane();
        JList jList1 = new JList();
        final JDialog jDialog1 = new JDialog(this,"Rendering Bug",true);

        /**Construct the frame*/
        public Frame1() {
          enableEvents(AWTEvent.WINDOW_EVENT_MASK);
          try {
            jbInit();
          }
          catch(Exception e) {
            e.printStackTrace();
          }
        }

        /**Component initialization*/
        private void jbInit() throws Exception {
          //setIconImage(Toolkit.getDefaultToolkit().createImage
      (Frame1.class.getResource("[Your Icon]")));
          DefaultListModel theListModel = new DefaultListModel();
          for (int i=100000; i<100100; i++) {
            theListModel.addElement(String.valueOf(i));
          }
          jList1.setModel(theListModel);
          contentPane = (JPanel) this.getContentPane();
          contentPane.setLayout(borderLayout1);
          this.setTitle("Frame Title");
          jScrollPane1.getViewport().add(jList1, null);
          jDialog1.getContentPane().add(jScrollPane1);
          jDialog1.setSize(new Dimension(1000,800));

          // Uncomment dialog pack to see improvement in rendering but not total
          // elimination of problem. To see rendering problems when dialog is packed,
          // expand frame to cover most of screen and then drag frame mostly offscreen
          // and then onscreen in a circle about lower right corner of screen. Vary
          // speed of dragging to force failure to render blocks in the frame.
      // jDialog1.pack();
          jDialog1.setVisible(true);
          this.validate();
        }
        /**Overridden so we can exit when window is closed*/
        protected void processWindowEvent(WindowEvent e) {
          super.processWindowEvent(e);
          if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            System.exit(0);
          }
        }
      }
      (Review ID: 125099)
      ======================================================================

            chaasesunw Chet Haase (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: