diff options
author | Carolyn MacLeod | 2009-03-03 16:35:53 +0000 |
---|---|---|
committer | Carolyn MacLeod | 2009-03-03 16:35:53 +0000 |
commit | 8515d73625205434c3e8ac5f78baa0d4112fffff (patch) | |
tree | f2f48116d81fb7048256585e91a9f8835af6f509 /examples/org.eclipse.swt.snippets | |
parent | 3862c6b3b8f0c2a32415ba364d344d184c244114 (diff) | |
download | eclipse.platform.swt-8515d73625205434c3e8ac5f78baa0d4112fffff.tar.gz eclipse.platform.swt-8515d73625205434c3e8ac5f78baa0d4112fffff.tar.xz eclipse.platform.swt-8515d73625205434c3e8ac5f78baa0d4112fffff.zip |
Change snippet to provide text that will be spoken for an image Button.
(because some AT's do not look for overridden text buttons)
Diffstat (limited to 'examples/org.eclipse.swt.snippets')
-rw-r--r-- | examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java index 2f945f4660..9cc4405050 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java @@ -11,38 +11,42 @@ package org.eclipse.swt.snippets; /* - * Override the text that is spoken for a native Button. + * Provide text that will be spoken for an image Button. * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; import org.eclipse.swt.accessibility.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class Snippet164 { -public static void main(String[] args) { - Display display = new Display(); - Shell shell = new Shell(display); - shell.setBounds(10, 10, 200, 200); +public static void main (String[] args) { + Display display = new Display( ); + Shell shell = new Shell (display); + 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"); - button1.setBounds(10,10,180,30); + button1.setText ("&Typical button"); + Button button2 = new Button (shell, SWT.PUSH); - button2.setText("&Overidden button"); - button2.setBounds(10,50,180,30); - button2.getAccessible().addAccessibleListener(new AccessibleAdapter() { - public void getName(AccessibleEvent e) { - e.result = "Speak this instead of the button text"; + button2.setImage (image); + button2.getAccessible ().addAccessibleListener (new AccessibleAdapter() { + public void getName (AccessibleEvent e) { + e.result = "Eclipse logo"; } }); - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) display.sleep(); + shell.pack (); + shell.open (); + while (!shell.isDisposed ()) { + if (!display.readAndDispatch ()) display.sleep (); } - display.dispose(); + image.dispose (); + display.dispose (); } } |