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

NPE when closing modal dialog

XMLWordPrintable

    • 7
    • b14
    • x86
    • linux
    • Verified

        Run the test, you will see two frames and one modal dialog, close the dialog, NPE occured.
        Also you may noticed that second frame may be moved above modal dialog.

        import java.awt.Dialog;
        import java.awt.Frame;

        import java.awt.event.WindowAdapter;
        import java.awt.event.WindowEvent;

        public class npe_test {
            public static void main(String[] args)
            {
                Frame frame1 = new Frame("frame 1");
                frame1.setBounds(0, 0, 100, 100);
                frame1.setVisible(true);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException ie) {
                    ie.printStackTrace();
                }
                Frame frame2 = new Frame("frame 2");
                frame2.setBounds(150, 0, 100, 100);
                frame2.setVisible(true);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException ie) {
                    ie.printStackTrace();
                }

                Frame frame3 = new Frame("frame 3");
                Dialog dialog = new Dialog(frame3, "dialog", true);
                dialog.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent we) {
                            we.getWindow().dispose();
                        }
                    });
                dialog.setBounds(300, 0, 100, 100);
                dialog.setVisible(true);
                frame1.dispose();
                frame2.dispose();
                frame3.dispose();
            }
        }

              son Oleg Sukhodolsky (Inactive)
              son Oleg Sukhodolsky (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: