RE: java gui accessibility

  • From: "Sina Bahram" <sbahram@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 23 Feb 2008 22:49:36 -0500

This is possible, but it can get dirty ... here's some code to do it:

        KeyListener kl;
        kl = new KeyAdapter ()
        {
        public void keyPressed(KeyEvent e)
        {
// ignore shift and also higher characters
if(e.getKeyCode() == KeyEvent.VK_SHIFT || e.getKeyChar() > 127)
        return;

char ch = e.getKeyChar() ;

// do something with ch, if you want
}

Then, you have to add it to the event monitar, like this.

AWTEventMonitor.addKeyListener(kl);

Notice that's a static class, so just use an import to get access to it,
like this:

import com.sun.java.accessibility.util.AWTEventMonitor;

Also notice that you'll need the java access bridge to make this work.

No, this isn't the only way, but the other ways are too slow in my opinion,
so this is the only way I found to get good results in the screen reader
I've been working on.

Take care,
Sina

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall
Sent: Saturday, February 23, 2008 8:07 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: java gui accessibility

I recently emailed the list asking how to get the keycode of a key as soon
as it is pressed.  I have learned that that is not possible in a windows cmd
line (console") app and that I will have to write a simple gui if I want to
do this, which I really do.  If I write this gui, will I be able to use it
with jaws? I would want it to get the keypress and react depending on the
key, eventually using sounds but for now I need to use speech.  
Basically I want to hit a key and have the prog print text depending on the
key, have jaws read it, but always be able to hit another key.  I have no
experience with java gui stuff; I have never touched java.awt.  I don't want
to know so much how to do this as is it even possible and, if so, will jaws
read the text I print?

Have a great day,
Alex
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: