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

Access bridge can't always get focused component from the accessibility utilitie



    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.0.3
    • Component/s: client-libs
    • Labels:


      Name: dk106046 Date: 07/03/2002

      1.3 Accessibility Utilities

      Steps to reproduce:
      -Make sure that the access bridge is being loaded (edit accessibility.properties).
      -Run the test: java Test.
      -Initiate the screen reader JAWS (4.0) and immediately select the Start button from
      the Test window.
      -When the Names dialog opens you should see the focus on the "Name List:" combobox.
      JAWS reads "Names dialog", not "Name list: combobox Name 0" as expected.
      -Use the down arrow to open the combobox's drop down menu.
      -Use the down arrow to move down through the list checking that the items are read.
      When you hit the end of the visible scroll area (Name 7) use the down arrow to move the next item (Name 8) and the list will scroll so it is visible. JAWS reads "unavailable", not "Name list: combobox Name 8" as expected.
      -If you stop and restart Test without stopping JAWS and repeat the above steps the combobox and its item will be read correctly.

      =============================Test case code start=============================

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

       * The main window for the Test
      class Test extends JFrame {
          private JDialog dialog;
          private String[] nameList;
           * run Test
          public static void main(String args[]) {
              Test t = new Test();

           * Constructor
          Test() {
              nameList=new String[11];
              for(int i=0;i<11;i++){
                  nameList[i]="Name "+i;
           * Initialize the Test window with the necessary components
          private void initWindow() {
              getContentPane().setLayout(new GridBagLayout());
              JPanel panel=new JPanel();
              panel.setLayout(new GridLayout(2,1));
              final JButton button1 = new JButton("Start");
              button1.addActionListener(new ActionListener(){
                      public void actionPerformed(ActionEvent e) {
              final JButton button2 = new JButton("Finished");
              button2.addActionListener(new ActionListener(){
                      public void actionPerformed(ActionEvent e){
           * display the main Test window
          void displayTest(String args[]) {
              addWindowListener(new WindowAdapter(){
                      public void windowClosing(WindowEvent we) {
              getContentPane().setLayout(new GridBagLayout());
           * display the name selection dialog
          void displayNameDialog() {
             dialog = new JDialog( this, "Names", true);
             dialog.getContentPane().setLayout(new GridLayout(5,1));
             JLabel label = new JLabel("Name list:");
              final JComboBox choice = new JComboBox(nameList);
             choice.addItemListener(new NameMenuListener());
             label = new JLabel("Selected name:");
             JTextField tf = new JTextField(30);
             JButton cancelJButton = new JButton(("Cancel"));
             cancelJButton.addActionListener(new ActionListener(){
                      public void actionPerformed(ActionEvent e) {
           * Event handler for Name Popup Menu
          class NameMenuListener implements ItemListener {
              public void itemStateChanged(ItemEvent e) {
                  JComboBox prin = (JComboBox)dialog.getContentPane().getComponent(1);
                  JTextField nameField = (JTextField)dialog.getContentPane().getComponent(3);
                  if (((String)e.getItem()).equals(nameList[0])) {
                  } else{
                      for(int i=1;i<11;i++){
                              nameField.setText("Name "+i+" in the list");

      =============================Test case code end=============================

      Problem analysis:
      JAWS sometimes does and sometimes doesn't read the comboBox items which are outside of the scrollpanes visible area until they are selected (using the up/down arrow) and the scrollpane is scrolled to make them visible. This is a timing issue and is a problem with AWTEventMonitor in the Accessibility Utilities package (jacces.jar 1.3) rather than the 1.4.0 jdk.

      For the situation described above (selecting an item currently outside the scrollpane's visible area) it looks as if when the list selection changes JAWS is notified that the AccessBridge has received an ACCESSIBLE_SELECTION_PROPERTY PropertyChangeEvent. JAWS then gets the currently focused component by picking up the componentWithFocus field from the AWTEventMonitor. If this is none null then it goes down through the children until it gets the combobox's list and then uses getAccessibleChildren() on the list to go through all the children until it finds the selected one.

      However depending on the timing between when you start JAWS and when you start Test then sometimes AWTEventMonitor.AWTEventsListener.installListeners(Component c, int eventID) is not called for the comboBox with EventID.FOCUS until after focusGained() has been called on all of the combobox's focus listeners. This means that the AWTEventMonitor.AWTEventsListener has not yet been added to the combobox, so when the combobox gets focus AWTEventMonitor.AWTEventsListener.focusGained() is not called and so the AWTEventMonitor field componentWithFocus is left at null. Therefore when JAWS looks for the component with focus it finds null and stops without picking up the selected item in the combobox's list.

      This can be fixed within the Accessibility Utilities package by modifying the AWTEventMonitor.AWTEventsListener.installListeners(Component c, int eventID) code so that when the eventID is EventID.FOCUS:

              case EventID.FOCUS:
                  if((c!=componentWithFocus) && c.hasFocus()){//sc
                      componentWithFocus = c;//sc





            lmonsantsunw Lynn Monsanto (Inactive)
            dkorbel David Korbel (Inactive)
            0 Vote for this issue
            1 Start watching this issue