Java 辅助功能代码不工作

Java 辅助功能代码不工作,java,Java,我正在尝试用getAccessibleContext()编写GUI。setAccessibleName() 代码可以编译,但是我的屏幕阅读器“JAWS”除了窗口的标题外不会读取任何内容。 我甚至试着用鼠标点击按钮,但仍然看不到按钮文本 通常,按下shift键时,我应该在按钮之间跳跃,屏幕阅读器应该读取 顺便说一句,您不需要“JAWS”来测试代码。您可以使用Windows Naraator。在“所有程序”>附件>辅助功能>讲述者”下 这也不会读取按钮 代码如下: import java.io.*;

我正在尝试用getAccessibleContext()编写GUI。setAccessibleName() 代码可以编译,但是我的屏幕阅读器“JAWS”除了窗口的标题外不会读取任何内容。 我甚至试着用鼠标点击按钮,但仍然看不到按钮文本

通常,按下shift键时,我应该在按钮之间跳跃,屏幕阅读器应该读取

顺便说一句,您不需要“JAWS”来测试代码。您可以使用Windows Naraator。在“所有程序”>附件>辅助功能>讲述者”下 这也不会读取按钮

代码如下:

import java.io.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import javax.accessibility.*;


public class ggi{

public static void main( String args[] ){

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize( 400, 200 );
frame.setVisible(true);
frame.getRootPane().setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.BLACK));
frame.setTitle(" Testing access ");
frame.getAccessibleContext().setAccessibleName(" I am testing accessibility ");
frame.setLocationRelativeTo( null );
frame.setResizable( false );

JPanel panel= new JPanel();
frame.getContentPane().add( panel );
panel.setBackground( new Color( 100, 100, 100 ) );
panel.setLayout( null );
panel.getAccessibleContext().setAccessibleName(" This is a panel ");

JButton startR= new JButton(" Start ");
startR.getAccessibleContext().setAccessibleName(" Start  ");
panel.add(startR);
startR.setBackground( Color.black );
startR.setForeground( Color.white );
startR.setBorderPainted(false);
startR.setFocusPainted( false );
startR.setBounds( 10, 10 , 100, 25 );
startR.setToolTipText(" start New ");


final JButton stopR= new JButton("Stop ");
stopR.getAccessibleContext().setAccessibleName(" Stop  ");
panel.add( stopR );
stopR.setBounds( 150, 10 , 100, 25 );
stopR.setBackground( Color.black );
stopR.setForeground( Color.white );
//startR.setContentAreaFilled(false);
stopR.setBorderPainted(false);
stopR.setFocusPainted( false );
stopR.setToolTipText(" Stop  ");

}//main
}//class