1

Hello everyone,

So I am trying to make a program with Java and I am at the stage of designing the GUI, so I decided to test using the swing library. I made a simple testing project for checking how to use swing to make accessible GUI.

Right now I am somewhat stuck, so I was hoping someone with swing experience could give me some advice.

My test program isn’t accessible. All that it does is make a window with a single button. When the button is pressed, a simple message is printed to console. The problem is that when the window opens up i can navigate over to the window, but it claims the window has no objects and unknown focus. \even though the window clearly contains a button and even the system focus is on the button, since when I press spacebar, it fires off an Action event.

I will provide source code for theis test class at the end of the post.

If there is someone with experience with this, could they please let me know what I need to do to allow the screen reader to be able to read the information in the swing GUI.

By the way, I do have java access bridge enabled.

Source code:

package test;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
*  Testing class. Creates window with a single button.
*/
public class TestWindow extends JFrame  implements ActionListener {
    // test button
    private JButton button;

    public TestWindow() {
        // basic window properties
        super("test window");
        setLocationByPlatform(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        // try to set look and feel to system look and feel
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException
                | IllegalAccessException | UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }

// set up button
        button = new JButton("Press me");
// add the TestWindow as action listener
        button.addActionListener(this);
        // layout button on window
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(button, BorderLayout.CENTER);

        pack();

        // make window visible
        setVisible(true);
        // set focus to button
        button.requestFocus();
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // when button is pressed, print message to console
        System.out.println("I was pressed!");
    }

    // end of class
}

Thumbs up

2

Do you have the Java Access Bridge installed? You need that (and you need to run, as admin, jabswitch -enable) and restart your screen reader.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

3

thanks for the advice.

i used the command line to enable java bridge. i restarted everything, even my computer, but my test program that i provided the source code for in my post still doesn't create an accessible window.

the focus is still unknown and it claims the window has no objects

by the way, i am using NVDA, if that is at all relevant.

have you or someone else tried making GUI with swing? and did it work properly when java access bridge was enabled?

if so, would you or someone mind testing my little program, whether it produces the same inaccessibility issues.

Thumbs up

4

Do you have the 64-bit version of Java? If so, install the 32-bit version alongside it, and enable the JAB for both.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

5

unfortunatly it seems that hasn't done the trick. here is exactly what I did:
i checked which version of java i had installed. found i had both 64 bit and 32 bit.
i ran cmd.exe as administrator
ran the jabswitch - enable command for both versions of java
the console  responded with this message for both instances:
"Java access bridge has been enabled."
close cmd.exe
opened eclipse as admin, just to be super sure.
ran the test program.
Still unknown focus and window is detected as empty by NVDA...

Thumbs up

6

Do you use Jaws? I had the same Problem and strangely, Jaws couldn't read a single element but NVDA could.

Thumbs up

7

actually I am using NVDA, but I am having this problem...

Thumbs up

8

Hmmm... weird.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up