2 Replies Latest reply on Oct 21, 2008 4:16 PM by 843807

    How do I enable the Java Accessibilty Stuff?

      Hi. I'm trying to make my application accessible via a screen reader to impaired users. Unfortunately, I'm not having any success whatsoever. If I didnt know Java had accessibility stuff built-in, I would assume that it was just not compatible at all with screen reader technology.

      How do I enable the Java accessibility stuff so that UI components are accessible to a screen reader; they can be iterated over and get sensible names and/or descriptions of them?

      I wrote a simple application, attached below, which just makes a demo UI from which I can start learning the basics of the accessibility stuff. Out of the box, the UI is completely opaque to a screen reader (I'm using the VoiceOver utility bundled with Mac OS X, which does ok with normal applications).

      I tried setting things focusable to no avail, voice over cant cycle through the UI component using the normal keyboard short cuts, and nothing is spoken when I tab between components, despite some things having natural labels, like a menu, and some things, like the button, where i've set the accessible name and description on the accessible context of the component.

      Obviously, I'm doing something wrong or I just don't understand how the accessibility stuff works.

      Could someone please shed some light on this so that I can make my application accessible to a screen reader?

          private static void try508Example() {
              JFrame aFrame = new JFrame();
              JMenuBar aMenuBar = new JMenuBar();
              JMenu aMenu = new JMenu("Test");
              JMenuItem aItem1 = new JMenuItem("Test Item 1");
              aItem1.getAccessibleContext().setAccessibleName("Test Item 1");
              aItem1.getAccessibleContext().setAccessibleDescription("Test Item 1 Description");
              JMenuItem aItem2 = new JMenuItem("Test Item 2");
              JMenuItem aItem3 = new JMenuItem("Test Item 3");
              JTabbedPane aTabPanel = new JTabbedPane();
              JTextArea aTab1Comp = new JTextArea();
              JScrollPane aTab2Comp = new JScrollPane(new JTree());
              aTabPanel.addTab("Tab1", aTab1Comp);
              aTabPanel.addTab("Tab2", aTab2Comp);
              JTree aTree = new JTree();
              JLabel aLabel = new JLabel("some label");
              JScrollPane aScrollList = new JScrollPane(new JList());
              JButton aBtn = new JButton("Button");
              aBtn.getAccessibleContext().setAccessibleName("Button Name");
              aBtn.getAccessibleContext().setAccessibleDescription("Button Description");
              JPanel aContent = new JPanel(new BorderLayout());
              aContent.add(aBtn, BorderLayout.NORTH);
              aContent.add(aScrollList, BorderLayout.EAST);
              aContent.add(aTree, BorderLayout.WEST);
              aContent.add(aLabel, BorderLayout.SOUTH);
              aFrame.setSize(640, 480);
        • 1. Re: How do I enable the Java Accessibilty Stuff?
          Ok, so a very curious issue. If I comment out adding the menu bar to the window, ie comment out this line:


          The screen reader reads me back everything just like I would expect. I comment the line back in, and nothing, the application is completely invisible to the screen reader.

          Anyone have any idea what this is about?
          • 2. Re: How do I enable the Java Accessibilty Stuff?
            I'll send someone 5 real dollars if they can explain this behavior. I know Java is accessible, but my example program doesn't seem to work on any platform with any screen reader unless i dont add the menu bar. No menu bar yields an accessible application? That doesnt make sense.

            Any ideas?