Example usage for org.eclipse.swt.widgets Button getAccessible

List of usage examples for org.eclipse.swt.widgets Button getAccessible

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Button getAccessible.

Prototype

public Accessible getAccessible() 

Source Link

Document

Returns the accessible object for the receiver.

Usage

From source file:org.eclipse.swt.snippets.Snippet164.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 164");
    shell.setLayout(new GridLayout());
    Image image = new Image(display, Snippet164.class.getResourceAsStream("eclipse.png"));

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("&Typical button");

    Button button2 = new Button(shell, SWT.PUSH);
    button2.setImage(image);//from   w  w  w.  ja v a  2s . co m
    button2.getAccessible().addAccessibleListener(new AccessibleAdapter() {
        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Eclipse logo";
        }
    });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:org.eclipse.swt.examples.accessibility.AccessibleNameExample.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    shell.setText("Accessible Name");

    Button button = new Button(shell, SWT.PUSH);
    button.setText("Button"); // the first button's accessible name is "Button"

    Image image = new Image(display, AccessibleNameExample.class.getResourceAsStream("run.gif"));
    button = new Button(shell, SWT.PUSH);
    button.setImage(image);/*from  w w w . j  av a2  s . c  om*/
    button.getAccessible().addAccessibleListener(new AccessibleAdapter() {
        @Override
        public void getName(AccessibleEvent e) {
            e.result = "Running man"; // the second button's accessible name is "Running man"
        }
    });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}