我正在尝试创建一个可供屏幕阅读器访问的简单UI.我一直很成功,但我无法以屏幕阅读器读取新文本输出的方式设计UI.
目前,我有一个TextArea显示匿名PrintStream创建和设置的输出System.setOut.有时我打开一个TextFieldfor字符串输入,但我一直只是TextArea用来测试文本的读取(现在它只是监听按键以显示更多文本用于测试目的).
问题是:当通过System.out将新文本添加到TextArea屏幕阅读器时,屏幕阅读器不会读取它.我仍然可以使用箭头键向上导航以读取添加的内容,但在首次添加时不会读取.有没有办法让屏幕阅读器TextArea更像是一个标准控制台(在其中自动读取所有新文本)?我正在使用NVDA.
事情我已经尝试:
-使用TextArea.notifyAccessibleAttributeChanged(AccessibleAttribute.TEXT)
-使用TextArea.requestFocus()并TextArea.notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_NODE)
-对禁用自动冲洗PrintStream使用,而TextArea.setAccessibleText(theNewText)冲洗时
-使用一个隐藏的Label一套新的文字和关注它(我还在这一个摆弄;屏幕阅读器无法读取实际"隐藏的"文字,所以我试图找到一种方法来绘制它,但也是"看不见的",也许在TextArea某种程度上背后)
- 改变焦点到另一个Node和后面,这不是我喜欢的工作,因为它读取其他Nodes可访问东西,然后读取整个身体TextArea
- 这些的各种组合
我似乎无法让它工作.我觉得我在这里缺少一些简单而明显的东西,但JavaFX Accessibility API仍然相对较新,我无法找到像这样的特定问题的解决方案.
这是我的相关代码Application,如果有帮助的话:
@Override
public void start(Stage primaryStage) {
try {
primaryStage.setTitle("Test");
root = new BorderPane();
root.setFocusTraversable(false);
Scene scene = new Scene(root,800,600);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
//Create middle
output = new TextArea();
output.setEditable(false);
output.setFocusTraversable(false); //I've tried …Run Code Online (Sandbox Code Playgroud) 我将字段值maxSeats设置为表示将在主类中的最大座位数.主类:
public static void main(String[] args) {
Student a = new Student("Abigail", 1, 5);
Student b = new Student("Benny", 1, 6);
Student c = new Student("Charles", 1, 10);
Student d = new Student("Denise", 2, 12);
Student e = new Student("Eleanor", 2, 9);
Student f = new Student("Fred", 2, 5);
SchoolBus sb1 = new SchoolBus(3, 1);
SchoolBus sb2 = new SchoolBus(3, 2);
sb1.getRemainSeat();
sb1.addStudent("Benny", 1, 6);
}
Run Code Online (Sandbox Code Playgroud)
其他课程:
private int maxSeats;
private int routeNum;
String[] studentArray = new String[3];
public SchoolBus(int …Run Code Online (Sandbox Code Playgroud)