On Fri, 15 Jan 2021 08:29:44 GMT, Pankaj Bansal <pban...@openjdk.org> wrote:

> Create implementation for NSAccessibilityImage protocol peer

> @pankaj-bansal please provide some steps to test that a11y for the image 
> works.

I use the simple code snippet like this: 

<pre>
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.*;

public class AccessibleImageTest {
    public static void main(String[] args) throws MalformedURLException {
        new AccessibleImageTest().test();
    }

    public void test() throws MalformedURLException {
        JFrame frame = new JFrame("Test frame");
        frame.setLayout(new BorderLayout());
        ImageIcon imageIcon = new ImageIcon(new 
URL("https://www.oracle.com/a/ocom/img/i-code-java-300x352-3854596.png";));
        JLabel label = new JLabel(imageIcon);
        label.getAccessibleContext().setAccessibleDescription("I code Java");
        frame.add(label, BorderLayout.CENTER);
        frame.add(new JButton("Top button"), BorderLayout.NORTH);
        frame.add(new JButton("Bottom button"), BorderLayout.SOUTH);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}
</pre>

After compiling and running the code you should see frame with two buttons on 
top and bottom and image in the middle. Now if you turn on VoiceOver with 
`<Command><F5>` the accessibility cursor should be on one of the buttons. By 
using `<Control><Option><UpArrow>` and `<Control><Option><DownArrow>` 
combinations you should be able to move accessibility cursor between buttons 
and the image. If image accessibility implemented correctly the accessibility 
cursor should be drawn around the image borders and the VoiceOver should 
understand the selected element type and take accessible text of the image into 
account, so the narration should sound like "I code Java, image". Of course 
that also should work with the local images and icon images.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2096

Reply via email to