在Windows上直接获取Java可访问性 [英] Getting Java accessibility straight on Windows

查看:89
本文介绍了在Windows上直接获取Java可访问性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一位合法的盲人开发人员,使用C#,Java,PHP,JavaScript和其他一些语言和库。我认为自己是一个非常高级的爱好开发人员,并且很快就会开始学习计算机科学。

我知道我们将专注于Java作为编程语言,因此我决定选择一些旧项目。控制台应用程序对我而言不再具有真正的吸引力-我在那里做了很多事情。因此,我通常最终会创建GUI。使用PHP和HTML非常简单,在C#中也不太困难。当然,我需要视觉方面的帮助;但是我可以在WindowsForms和WPF框架中使用C#来建立可靠的GUI并在Windows上运行。

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.

具有讽刺意味的是,Java既是我在GUI创建中的首次尝试,也是我从未使它无法正常工作的唯一语言。

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

让我们保持简单:我要做的就是创建一个名为<$ c的基本消息对话框在$ c> Test 中输入文字 Hello world 。让我们看一下。

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);
  }
}

这不是火箭科学; JavaScript的警报函数和C#的 MessageBox 起到类似的作用。通常,当这样的消息对话框弹出时,我的盲文显示器将焦点放在确定或关闭按钮上,屏幕阅读器会宣布对话框的标题和消息,并且我还可以通过盲文显示键和/滚动来感知对话框的静态文本。或触摸光标(JAWS)和/或屏幕阅读器的相应特殊光标(例如JAWS光标或NVDA光标),它们是鼠标指针,可以在整个屏幕上移动,因此显然最终会落在静态文本上。

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.

但是在Java中会发生什么?

But what happens in Java?


  • 在JAWS下,将打开一个测试对话框。我没有看到任何消息,只有对话框标题,而且如果我使用触摸光标,我还会看到一个关闭按钮。

  • 在NVDA下,它与JAW下的相同,只是焦点不会移动。自动,并且看不到关闭按钮。

  • 旁白也自动移动焦点,但是就像NVDA无法感知关闭按钮一样。

我使用Java SDK 11,最新的Eclipse版本和Windows 10; NVDA版本18.3和最新的JAWS 19版本。我的软件是最新的,至少在JAWS中,我是一位专家用户,他了解大多数(如果不是全部)获取静态文本的方法。
这些方法都不起作用。

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.

有人碰巧知道Java可访问性如何吗?作品?我知道存在可访问的Java应用程序。我只是不知道如何创建它们。我对话框​​的问题只是最基本的问题-无法访问带有JFrame,按钮,文本字段等的更复杂的GUI。而且,尽管甲骨文基本上说
,只要您不理会我们的组件,并可能提供可访问的名称和描述,即可直接使用它们。

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.

任何

我在计算机上安装了NetBeans。不,确切地说,我在计算机上安装了NetBeans安装程序。安装程序无法访问。这本身并不罕见-令人惊讶的是,许多开发人员投入了大量心思创建可访问的应用程序,然后创建了无法访问的安装程序。因此,我会尽可能地坚持使用ZIP和手动配置(您知道,并不是在2000年代一切都变糟了,我很高兴看到那里的纯粹主义者和/或控制狂们鄙视安装程序)。

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).

但真正有趣的是:NetBeans安装程序看起来就像我用javax.swing创建的对话框和其他GUI一样。也就是说:NVDA和讲述人为空白(对话框/窗口名称除外),并且使用JAWS,如果我使用触摸光标,我还可以检测上下文菜单和关闭按钮。 Hooray,我有一个整个按钮可以与之互动! -只是它甚至没有响应我使用Enter或空格键单击它(没有尝试单击鼠标,因为我无法使用JAWS光标(也就是鼠标)找到此关闭按钮)。

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)).

我会继续研究。但是,如果此安装程序是用javax.swing编写的,而NetBeans也是用javax.swing编写的,那么它对于javax.swing的整体可访问性(对盲人来说)看起来并不好。另外,我将尝试与Oracle联系。毕竟,一定有充分的理由将他们在有关javax.swing的文档中放入默认情况下可访问性,并建议使用NVDA进行测试。当然,我只是想念他们实现的明显可访问性-毕竟,我只使用了屏幕阅读器十二年。

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。很抱歉,这很讽刺,但这种情况同样使我感到震惊和沮丧。毕竟,一家公司表示默认情况下可以访问其GUI类,而我作为聋哑用户和开发人员的经验告诉我,它们不是。

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.

就像注释中所建议的(感谢 VGR ),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.

推荐答案

请注意: 答案尚未完成。从本质上讲,我仍然需要转到Oracle并与他们讨论javax.swing。但是,我想将此添加为摆动的部分答案/替代方法,以便任何对此进行调查的人都可以找到有效的解决方案。

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.

我最近用Java创建了我的第一个完全可访问的GUI应用程序。它使用 SWT ,并且在Windows上的可访问性方面表现良好(已通过NVDA,JAWS和Narrator测试) 。正如这个问题专门针对Windows一样,这就是我们需要知道的。但是,如果有机会的话,我也会在Mac OS和GNU / Linux上测试该应用程序。

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.

考虑到SWT使用的是本机组件和可访问性行为,我怀疑任何操作系统上的标准组件都不会有任何问题。但是自定义组件又如何呢?

它们的表现也相当好。我发现的一个例外是CCombo-对于盲文显示用户,如果使用JAWS,它将显示为文本字段。但是,由于NVDA和Narrator正确地理解了它,甚至JAWS的行为都正确,我想JAWS是我们的罪魁祸首,而不是SWT。

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.

JFace呢?

由于JFace本质上是SWT的扩展,我怀疑它在可访问性方面应该没问题,但尚未进行检查。如果创建JFace应用程序,请花时间使用NVDA或至少使用Narrator对其进行可访问性问题测试。

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.

Microsoft提供的使C#应用程序可访问的任何建议也适用于SWT。 ,尽管执行某些操作的语法非常不同,并且有时在网页上类似于ARIA,而不是C#中的可访问性实现。看一下代码片段,以了解实现了各种可访问性方面(尽管如果标签不直接位于文本字段的左侧,则只需将标签和文本字段专门设置为关联)。

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.

这篇关于在Windows上直接获取Java可访问性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆