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

Initially modal blocked window causes modal dialog to lost focus

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 6
    • client-libs
    • b43
    • generic
    • linux

      When any Java toplevel window is being shown, it is checked, if it should be blocked by any visible modal dialogs. But even if it should, when it gets focus when shown. This can be illustrated by the following simple example:

      import java.awt.*;

      pubic class CauseDialogToLostFocus
      {
        public static void main(String[] args)
        {
          // parent frame
          Frame f = new Frame("F");
          f.setBounds(0, 0, 200, 100);
          f.setVisible(true);

          // toolkit-modal dialog d1
          final Dialog d1 = new Dialog(f, "D1", Dialog.ModalityType.TOOLKIT_MODAL);
          d1.setBounds(100, 100, 200, 100);
          // show d1 in a separate thread to leave this thread running
          new Thread(new Runnable()
            {
              public void run()
              {
                d1.setVisible(true);
              }
            });

          // application-modal dialog d2
          Dialog d2 = new Dialog(f, "D2", Dialog.ModalityType.APPLICATION_MODAL);
          d2.setBounds(200, 200, 200, 100);
          // d2 must be blocked by d1
          d2.setVisible(true);
        }
      }

      Run this test on linux/solaris w/ XToolkit. If the second dialog has focus (different WMs can mark this by highlighting the title or somehow else), the bug is reproduced.

      ###@###.### 2005-05-31 13:36:44 GMT

            art Artem Ananiev (Inactive)
            art Artem Ananiev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: