Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Java accessibility straight on Windows

The background

I'm a legally deafblind developer in C#, Java, PHP, JavaScript and some other languages and libraries. I consider myself a pretty advanced hobby developer and will soon start to study computer sciences.
I know we'll focus on Java as programming language, hence I decided to pick up some of my old projects. Console applications have no real appeal to me anymore - I've done most things there. So I usually end up creating GUIs. Using PHP and HTML, that's very easy, and in C# not too hard, either. Sure, I need help with visual aspects; but I can get a solid GUI up and running on Windows using C# both in WindowsForms and WPF framework. Accessibility has rarely been an issue there.

Ironically, Java was both my first attempt in GUI creation and the only language in which I never got it to work properly.

My problem

Let's keep this simple: All I want to do is create a basic message dialog named Test with the text Hello world in it. Let's have a look at it.

import javax.swing.JOptionPane;

public class GUITest {
  public static void main(String[] args) {
    JOptionPane.showMessageDialog(null, "Hello world!", "Test", JOptionPane.INFORMATION_MESSAGE);
  }
}

This isn't rocket science; JavaScript's alert function and the MessageBox of C# do similar things. Usually when such a message dialog pops up my braille display is focused on an OK or Close button, the screen reader announces the dialog title and message, and I can also perceive the static text of the dialog using scrolling via my braille display keys and/or the touch cursor (JAWS) and/or the respective special cursors of the screen reader like JAWS cursor or NVDA cursor, which is the mouse pointer and can get moved all over the screen, so obviously eventually lands on the static text.

But what happens in Java?

  • Under JAWS, a Test Dialog opens. I see no message, just the dialog title and if I use the touch cursor I also see a Close button.
  • Under NVDA, it's the same as under JAWs, except focus doesn't move automatically and I can't see the close button.
  • Narrator moves the focus automatically also, but just like NVDA does not perceive the close button.

I use Java SDK 11, the latest Eclipse version, and Windows 10; NVDA version 18.3 and the latest JAWS 19 version. My software is pretty up to date, and at least in JAWS I'm an expert user who knows most, if not all, methods to get static text. None of these methods worked.

The question

Does anyone happen to know how Java accessibility works? I know accessible Java applications exist; I just have no clue how to create them. My problem with the dialogs is just the most basic of problems - more complex GUIs with JFrames, buttons, text fields etc. are just as inaccessible. And that although Oracle basically says as long as you leave our components alone and maybe give accessible names and descriptions they're accessible out of the box.

Any input which might explain what I'm missing would be much appreciated.

Further research

javax.swing

I installed NetBeans on my computer. No, to be precise, I installed the installer of NetBeans on my computer. The installer is... inaccessible. That in itself isn't unusual - surprisingly, many developers who put lots of thought into creating an accessible application then create inaccessible installers. Hence I stick to ZIPs and manual configuration as often as I can (you know, not everything was worse in the 2000s, and I'm actually glad there are purists and/or control freaks out there who despise installers).

But the really interesting thing is: The NetBeans installer looks just like my inaccessible dialogs and other GUIs I created with javax.swing. That is: blank (except for the dialog/window name) for NVDA and Narrator, and with JAWS I can additionally detect the context menu and a close button if I use the touch cursor. Hooray, I got an entire button to interact with! -- Just that it doesn't even respond to me clicking on it with enter or space bar (didn't try mouse click, as I can't find this close button using JAWS cursor (aka the mouse)).

I'll keep researching. But if this installer is written in javax.swing, and if NetBeans is written in javax.swing also, then it doesn't look good for javax.swing's overall accessibility (for the blind). Also, I'll try to reach out to Oracle. After all, there must be a good reason they put "accessibility is available by default" in their doc about javax.swing and suggested testing with NVDA. Surely I'm just missing the obvious accessibility they implemented -- after all, I only used screen readers for twelve years.

PS. Sorry for the sarcasm, but this situation equally amuses and frustrates me. After all, a company says their GUI classes are accessible by default, and my experience as a deafblind user and developer tells me they're not.

Standard Widget Toolkit (SWT)

Just as suggested in the comments (thanks, VGR), SWT is indeed accessible, at least the base classes. This is not surprising given it uses native widgets when possible -- still, good to know.

like image 739
TimB Avatar asked Aug 20 '19 13:08

TimB


People also ask

How to enable Java Access bridge in windows 10?

Navigate to "Control Panel > Ease of Access > Ease of Access Center > Make the computer easier to see" and enable the option "Enable Java Access Bridge".

What does Java Access Bridge do?

Java Access Bridge is a technology that exposes the Java Accessibility API in a Microsoft Windows DLL, enabling Java applications and applets that implement the Java Accessibility API to be visible to assistive technologies on Microsoft Windows systems.


1 Answers

Please note: This answer is not complete yet. Essentially I still need to go to Oracle and talk to them about javax.swing. Nonetheless, I want to add this as a partial answer/alternative to swing, so anyone investigating into this gets pointed to a working solution.


I recently created my first fully accessible GUI application in Java. It uses SWT and performs smoothly in terms of accessibility on Windows (tested with NVDA, JAWS and Narrator). As this question specifically refers to Windows, that's all we need to know. However I'll test the app on Mac OS and GNU/Linux too if I ever get the chance to and will add the appropriate info.

Taking into account SWT uses the native components and accessibility behavior, I suspect there won't be any issues with the standard components on any OS. But what about the custom components?
They behave reasonably well, too. One exception I found is the CCombo - for braille display users, it gets displayed as a "text field" if you use JAWS. As NVDA and Narrator perceive it correctly and even JAWS behaves sort of correctly, though, I guess JAWS is our culprit here, not SWT.

What about JFace?

As JFace is basically an extension of SWT, I suspect it should be fine in terms of accessibility, but haven't checked that yet. If you create JFace applications, take the time to test it for accessibility issues using NVDA or at least Narrator.

Any advice Microsoft gives for making C# applications accessible also applies to SWT, though the syntax to do certain things is quite different and sometimes resembles ARIA on webpages more than the accessibility implementation in C#. Have a look at the snippets to see various accessibility aspects getting implemented (though you only need to specifically set label and text field into relation if the label isn't directly left of the text field).

I hope this is helpful so far and I'll keep doing research.

like image 135
TimB Avatar answered Oct 19 '22 00:10

TimB