VoiceOver Cursor Navigates Invisible Components

XMLWordPrintable

      When using Apple's VoiceOver tool on a Swing application: the VoiceOver cursor can navigate to JComponents that are inside hidden JPanels. VoiceOver thinks these components are positioned at (0,0) (overlapping the menubar). Also VoiceOver can interact with these components. For example: I'm able to use VoiceOver to programmatically "click" a JButton.

      Steps to reproduce:
      1. Run the app below
      2. Turn on VoiceOver (usually by pressing CMD + 5)
      3. (If needed: press CMD + TAB to put this app back in the foreground)
      4. Use CTRL + ALT + [left/right] keys to navigate around the app.

      Expected behavior: you can can navigate to the 3 colored window titlebar buttons (close, minimize, fullscreen)

      Observed behavior: you can navigate to those 3 buttons AND a hidden JButton that VoiceOver identifies as being in the top-left corner. Also: you can press CTRL + ALT + SPACE to make VoiceOver "click" the button.

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

      public class VisibilityBug2 {
          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      JFrame f = new JFrame();
                      JPanel panel = new JPanel();
                      JButton button = new JButton("Button");
                      button.addActionListener(e -> Toolkit.getDefaultToolkit().beep());
                      panel.add(button);
                      panel.setVisible(false);
                      f.getContentPane().add(panel);
                      f.pack();
                      f.setVisible(true);
                  }
              });
          }
      }
      ```

            Assignee:
            Jeremy Wood
            Reporter:
            Jeremy Wood
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: