arrows key binding

hi,

when im using the setMnemonic() function to bind a key i have to press alt+key in order to get the actionlistner is there a simple way to bind it without pressing the alt?

here is my sample code:

b1 = new JButton(leftButtonIcon);

b1.setMnemonic(KeyEvent.VK_LEFT);

b1.setActionCommand("left");

public void actionPerformed(ActionEvent e) {

if ("right".equals(e.getActionCommand())) {

System.out.println("right");

} else if ("left".equals(e.getActionCommand())) {

System.out.println("left");

} else if ("up".equals(e.getActionCommand())) {

System.out.println("up");

} else {

System.out.println("down");

}

}

thx.

[722 byte] By [barakyesha] at [2007-11-27 5:37:20]
# 1

You got lots of help in your last posting. Don't you think you should take the time to thank the people for the time they spent helping you before you start asking other questions?

Since you don't seem to appreciate the help you where given the last time I won't give you a direct answer but I'll let you find the answer on your own.

If you read the [url http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]Swing tutorial[/url] you will find out how key bindings work.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-12 15:09:18 > top of Java-index,Desktop,Core GUI APIs...
# 2
u r right im very sorry thx 4 the reply
barakyesha at 2007-7-12 15:09:18 > top of Java-index,Desktop,Core GUI APIs...
# 3
and the enlightment
barakyesha at 2007-7-12 15:09:18 > top of Java-index,Desktop,Core GUI APIs...