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

Multiple modal dialogs can be created before block takes effect

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.1.3, 1.2.2
    • Fix Version/s: 1.2.2_005
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      005
    • CPU:
      x86, sparc
    • OS:
      solaris_2.5.1, windows_nt
    • Verification:
      Verified

      Backports

        Description



        Name: joT67522 Date: 10/27/97


        /*
         * java.awt.Dialog blocking bug
         * Jason Mathews
         * Fri, Oct 24, 06:11:17 PM
         *
         * Problem: Modal dialogs do not block fast enough allowing for multiple
         * modal dialog instances to be created before the block is enabled.
         *
         * Clicking on the "Create Modal Dialog..." button on applet/frame several
         * times in rapid succession brings up multiple dialog windows. It appears
         * that there's a race condition of whether the first modal dialog
         * invokes the modal block or the subsequent Button events are processed by
         * the applet's event handler. The create dialog button event is handled
         * before the first modal dialog instance invokes the modal block, hence
         * multiple dialogs are created when you only want one.
         *
         * Works as expected under JDK 1.0.2 where blocking
         * is immediate. However, the modal block in
         * JDK 1.1.3 is slow to respond to the lock.
         *
         * Same behavior on SGI/IRIX 5.3 and DEC Alpha OSF.
         */

        import java.awt.*;
        import java.applet.*;

        class TestDialog extends Dialog {

          public TestDialog(Frame parent, String title) {
            super(parent, title, true);
            System.err.println("create: " + title);
            setLayout(new BorderLayout(15,15));
            // do something that takes a little time
            for (int i=1; i < 100000; i++)
              new Integer(i);
            add("Center", new Label("This a test", Label.CENTER));
            add("South", new Button("Ok"));
            resize(200,80);
            System.err.println("show: " + title);
            show();
          }

          public boolean action (Event e, Object arg) {
            if (e.target instanceof Button) {
              hide();
              dispose();
              return true;
            }
            return false;
          }

        }

        ------- BugDialog.java ----------


        import java.awt.*;
        import java.applet.*;

        public class BugDialog extends Applet {

          int count = 1;
          boolean workaround = false;

          public BugDialog() {
            add(new Button("Create Modal Dialog..."));
            add(new Checkbox("Enable workaround"));
            resize(100,100);
          }

          public boolean action(Event e, Object o) {
            if (e.target instanceof Button) {
              Container parent = getParent();
              while (parent != null && ! (parent instanceof Frame) )
        parent = parent.getParent();
              if (workaround) disable();
              new TestDialog((Frame)parent, "Modal Dialog " + count++);
              if (workaround) enable();
            } else if (e.target instanceof Checkbox) {
              workaround = ((Checkbox)e.target).getState();
              System.err.println("workaround " + workaround);
            } else {
              return false;
            }
              return true;

          }
          
          public static void main (String args[])
          {
            Frame f = new Frame("BugDialog");
            BugDialog d = new BugDialog();
            d.init();
            d.start();
            f.add("Center", d);
            f.pack();
            f.show();
          }

        }
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tmasunw Tao Ma (Inactive)
                  Reporter:
                  johsunw Joon Oh (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: