18
votes

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.

2
Most of Swing provides accessibility automatically, so I’d say you’re doing everything right. This page even specifically recommends testing with NVDA.VGR
@VGR Agreed, that's what I heard too. But I don't see this "automatically" they're talking about... Even after using all my "somehow fetch static text"-tricks I didn't manage to read the content of the dialog. Same got for JOptionPane.showInputDialog() -- I can't even see there's an input field, not to mention the content of that field. And that's the case since I started using Java in 2016 with Java 8.TimB
I also know there MUST be a way to make Java applicationsaccessible, as Eclipse itself is written in Java as far as I know, and that thing IS accessible (or at least accessible enough). But how are they doing it as I'm already following their recommendation? I'm so puzzled.TimB
I believe Eclipse uses SWT, not Swing. I would be interested in how well Netbeans adheres to accessibility standards.VGR
@VGR Will check this and let you know. It's worth a try...TimB

2 Answers

1
votes

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.

0
votes

I am a developer who is currently working on GUI applications in JAVA. I recommend you use JFX for building GUI applications in JAVA as it has been enhanced from standard Swing and AWT and SWT. It was meant to replace Swing. Also I would recommend you to enable Java access bridge located in your JRE runtime environment to check windows accessibility created using the Swing or AWT or SWT.

Try enabling like this To enable Java Access Bridge, run the following command (where %JRE_HOME% is the directory of your JRE):

%JRE_HOME%\bin\jabswitch -enable Alternatively, in Windows Vista and later, you can enable Java Access Bridge through the Control Panel:

Go to Start -> Control Panel -> Ease of Access -> Ease of Access Center. Select Use the computer without a display. In the section Other programs installed, select the check box Enable Java Access Bridge. Just check this and do let me know if this answers your question.