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

Focus transfer do not happen when modal dialog is closed

    XMLWordPrintable

Details

    • Fix Understood
    • x86
    • windows_xp

    Description

      This is reproducible starting jdk6 on Windows platforms
      Run the below testcase. It shows a Window with a button in it. On clicking the button, it shows a modal Dialog. On clicking a button on the modal dialog, a Frame is shown. Since the modal dialog is visible, Frame will be blocked. On clicking a 'Close' button on modal dialog, it closes. Now, even though there's a Frame visible, it doesn't get focus.

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

      public class FocusTest {
          
          private static Dialog d;
          private static Frame f;
          
          public static void main(String[] args) {
              f = new Frame();
              f.setLayout(new FlowLayout());
              f.add(new Button("Click Me"));
              f.setSize(150, 150);
              f.setLocation(200, 200);
              
              d = new Dialog(new Frame());
              d.setLayout(new FlowLayout());
              Button db = new Button("Open Frame");
              db.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                      f.setVisible(true);
                  }
              });
              d.add(db);
              Button dClose = new Button("Close");
              dClose.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                      d.dispose();
                  }
              });
              d.add(dClose);
              d.setModal(true);
              d.setSize(150, 150);
              d.setLocation(0, 200);

              Window w = new Window(new Frame());
              w.setSize(150, 150);
              Button wb = new Button("Open Dialog");
              wb.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                      d.setVisible(true);
                  }
              });
              w.setLayout(new FlowLayout());
              w.add(wb);
              w.setVisible(true);
          }
      }

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Imported:
                Indexed: