Search code examples
javaswingaccessibilitynvda

How to let NVDA read Swing / GUI elements


I am using the Eclipse ide for Java development. When I execute the following code, the NVDA only reads ‘This is a frame’. It doesn’t read the button.

import javax.swing.; import javax.accessibility.;

public class MyButton {
    public static void main(String [] args) {
        JFrame f = new JFrame ("This is a frame");
JButton b = new JButton ("This one is a button");
    b.setBounds(50,100,95,30);
//f.add(b);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
b.setToolTipText("This tooltip makes the button accessible");;
}
}

**I have enabled AccessBridge via Ease of Access Center. I’m using Eclipse and NVDA on Windows 10.


Solution

  • Normally, it should work. You can try the following things:

    • Make sure the access bridge is enabled
    • restart NVDA and your app, or even reboot, after having installed and enabled access bridge
    • If you are on a 64 bit system, try both 32 and 64 bit JVM. Only one of the two may work.
    • Make sure that the focus indeed goes to the button and don't stay on the framm. The focus can be in an half-dead position where you can't read anyhting and where tab does nothing.
    • Java 8: check that jre\lib\accessibility.properties contains a line like assistive_technologies=com.sun.java.accessibility.AccessBridge. I don't know if something similar still exists for Java 11+.

    Note that Swing and access bridge are old and kind of deprecated. For newer projects, you should use another GUI library. To make accessible GUI, you can for example use SWT instead.