views:

259

answers:

4

I'm trying to implement a very, very simple accessibility test for Swing so I can get a handle on how big a piece of work it will be to provide accessibility support for our already established Swing application.

I have the most simple Swing program, and I'm using Narrator in Windows Vista to attempt to screen-read its GUI.

public class ReadableFrame extends JFrame {

     private ReadableFrame() {
         super();

         setTitle( "Banjollity's Window" );
         setSize( 640, 580 );
         setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );

         JButton button = new JButton( "Hello World" );

         getContentPane().setLayout( new FlowLayout() );
         getContentPane().add( button );

         setVisible( true );
     }

    /**
     * @param args
     */
    public static void main( String[] args ) {
        new ReadableFrame();
    }
}

Narrator can read the title but nothing else. I get "Banjollity's Window, contains no other known controls". If I replace the Swing JButton with an AWT Button like so:

Button button = new Button( "Hello World" );

...then it works properly, and I get "Banjollity's Window, focus on Hello World button, contains Hello World button".

I've tried installing the Java Access Bridge to JRE/lib/ext (and I strongly suspect this is working properly as my program refused to start up my application until I put the DLLs in Windows/System32) but to no avail.

Can anybody help, or share a few suggestions?

A: 

As your findings with Button shows if Narrator is willing to read labels on native Windows applications then you could perhaps use heavy weight components so the OS becomes aware of them and in turn Narrator will read them.

kd304
@kd304 I need it work with Swing I'm afraid. We've got an established Swing application we're looking to add accessibility to.
banjollity
If you use swing, that doesn't rule out AWT components - except you don't like the native appearance. At least for labels you can try it.
kd304
A: 

It seems this is some issue with Narrator. If I use JAWS with my Java Access Bridge-enabled VM then it reads each component on the screen just fine.

banjollity
+2  A: 

You don't, Narator is a bad screen reader. You need to install the java access bridge, and then use either jaws that will run for 40 minutes at a time as a demo or NVDA which is a free screen reader that also supports Java.

Jared
A really nice feature of NVDA is that it supports a mode where the spoken text appears in a floating window, so you don't have to listen to a creepy computer voice while developing for it.
Joe Attardi
A: 

Unfortunately your swing components need to implement the IAccessible interface, once that is done, Narrator can discover the components and read their content. Without that there's no way for it to discover the controls.

Larry Osterman