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

Modal dialogs using 1.02 style events hang

XMLWordPrintable

    • x86, sparc
    • solaris_2.6, solaris_9, windows_95



      Name: mc57594 Date: 02/26/97


      Modal dialog boxes using the old event model hang. Try the "About..." box (under Help) in my Image/J applet at http://rsb.info.nih.gov/IJ/ for an example. This dialog is based on the InfoDialog class ("http://www.ora.com/catalog/javanut/examples/section5/InfoDialog.java") from "Java in a Nutshell".

      company - National Institutes of Health , email - ###@###.###
      ======================================================================

      New Test to reproduce bug. Please see Note: in testcase to see how to reproduce
      the bug.

      /*
       * JAVA AWT LIBRARY TEST
       *
       * FileName : bug_4058817_app.java
       * Purpose : To ensure correctness wiith Dialog show and dispose. This test
       * will test for a deadlock of a spawned dialog frame.
       * Created by : Ron Mann and Gary Collins on 11/25/97
       *
       * Note: Steps to test program
       * 1: Start the test by typing the following.
       * java bug_4058817_app 10
       * 2: The 10 is the number of Dialog threads you would like to run the tests.
       * The test needs to hava a minimal of 3 dialogs with the test repeated
       * 2 times per plateform.

       * pass = program will terminate by itself. Return code 0
       * fail = The User will have to terminate the program by hand. Usually Control C
       * will do the trick.
       *
       */

      import java.awt.event.*;
      import java.awt.*;
      import java.lang.*;

      public class bug_4058817_app
      {
        public static void main( String args[] )
        {
          int numdlgs = 1;
          int i;
      Frame f = new Frame();

      if ( args.length > 0 )
      numdlgs = Integer.parseInt(args[0]);
      System.out.println ( "Creating " + numdlgs + " Modal Dialogs\n");

      for ( i = 0; i < numdlgs; i++ )
      {
      DlgThread dt = new DlgThread();
      dt.setData(f);
      dt.nthreads = i;
      dt.checknumdlgs = numdlgs;
      dt.start();

      }
        }
      }

      class DlgThread extends Thread implements ActionListener
      {
        Dialog d;
        Frame f;
        int nthreads;
        int count = 0;
        static int loop = 0;
        int checknumdlgs = 0;
        Dialog nd;
        
        public void setData ( Frame frame )
        {
          f = frame;
        }
        
        public void actionPerformed (ActionEvent ev )
       {
         if ( count == 0 )
          {
             nd = new Dialog ( f,"I am new Dialog", true );
             Button b = new Button("I Kill YOU!");
             nd.add ( b );
             b.addActionListener( this );
             count++;
             loop++;
             nd.pack();
             nd.setLocation( (nthreads + 2 ) * 50, (nthreads + 2 ) * 50 );
             d.dispose();
             nd.setSize(200,200);
             nd.setVisible(true);
          }
         else {
           nd.dispose();
           count = 0;
           System.out.println("Loop: "+loop+"(checknumdlgs: "+(checknumdlgs));
           if (loop == (checknumdlgs)) {
             System.out.println("Programed worked as designed");
             System.exit(0);
           }
         }
       }
        public void run()
        {
          Button b = new Button("Quit");
          String hello = new String( "I am Thread " + nthreads );
          d = new Dialog ( f, hello, true );
          
          d.add ( b );
          b.addActionListener( this );
          nthreads++;
          System.out.println(nthreads);
          d.pack();
          d.setLocation( nthreads * 50, nthreads * 50 );
          d.setSize(200,200);
          d.setVisible(true);
        }
      }

      gary.collins@East 1998-07-15

            bchristi Brent Christian
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: