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

Focus lost forever after closing window by Alt+F4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 5_ea, 1.4.0
    • client-libs
    • sparc
    • solaris_8

      [Solaris 5.8](CDE)
      Merlin (build 87)

      After closing window by Alt+F4 only WindowClosed Event came(none Focus lost, gained) and focusOwner is still last focused component from closed window. It means that it isn't possible get focus back "into" runned application. This is high-priority issue from A11Y point of view, too.

      ====================================

      This is the attached Test :

      import java.awt.*;
      import javax.swing.*;

      public class Test_4531076 extends javax.swing.JFrame {
          
          /** Creates new form Test_4531076 */
          public Test_4531076() {
              JButton jButton1 = new JButton();
              getContentPane().setLayout(new java.awt.FlowLayout());
              jButton1.setText("Open dialog");
              jButton1.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                      jButton1ActionPerformed(evt);
                  }
              });
              getContentPane().add(jButton1);
              pack();
          }
          
          private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
              JDialog dialog = new JDialog(this,true);
              dialog.getContentPane().setLayout(new java.awt.FlowLayout());
              JLabel jLabel1 = new javax.swing.JLabel();
              jLabel1.setText("Close me : Alt + F4");
              dialog.getContentPane().add(jLabel1);
              dialog.pack();
              dialog.show();
          }
          
          public static void main(String args[]) {
          
              new Test_4531076().show();
              
              java.awt.Toolkit.getDefaultToolkit().addAWTEventListener(
              new java.awt.event.AWTEventListener() {
                  public void eventDispatched(java.awt.AWTEvent event) {
                      System.out.println(event.toString());
                      KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
                      Component c = kfm.getFocusOwner();
                      System.out.println("------ Focus Owner is : "+c);
                  }
              },
              java.awt.AWTEvent.WINDOW_EVENT_MASK |
              java.awt.AWTEvent.FOCUS_EVENT_MASK
              );
              
          }
          
          
      }

      =================================

      1. compile Test_4531076
      2. run it
      3. open dialog ( click on button "Open dialog" )
      4. close dialog by hitting Alt+F4
      -> now you can see focus owner after closing dialog, focus owner is still closed JDialog ( or null - happends sometimes 1/5)

      It's reproducible on Solaris 5.8(CDE).

            dmikhalksunw Denis Mikhalkin (Inactive)
            mmirilov Marián Mirilovič (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: