JtextField and Key Enter Event ...

... I know there are many post here with this question, but

i haven't found a suitable answer for that.

First let me resume what i have found:

Trying to capture the Enter Key Event seems to be senseless. Some says the Enter Key Event fire an ActionEvent and can't be captured as a Key Event. So you have to use an ActionEvent on the JTextField to be able to do something when the enter Key is pressed.

It's very short, but it is what i have found out in these posts.

So my question is will be simple : If I use ActionEvent in the JTextField, can I be certain to capture only the Enter Key Event ? And How implementing it correctly so that only the Enter Key Event will allow the call of the code to do ?

The reason for this post is that I have around eight JTextFields for collecting specific datas, and if the user hit Enter, I will have to check the data entry of the focused JTextField, and then if the data are correct, move the focus to the next JTextField. I am able to check the data when the focus is lost, or give the focus to the Next JTextField, but I'm quite unable to associate it with the Enter Key.

BTW if someone know how to capture the Tab button so that it make the same stuff ?

In Advance thanks, and sorry for posting these ennoying questions.

Marc.

[1350 byte] By [marc_huhardeaux] at [2007-9-26 4:18:42]
# 1
seems nobody can answer my questions.
marc_huhardeaux at 2007-6-29 17:20:51 > top of Java-index,Archived Forums,Swing...
# 2

Hi,

I have a JTextfield and when the user presses the Enter key I need to change the focus to the next component.

I am able to detect the enter key but can't find a suitable way to change the focus.

It looks like you have done that. Can you help me out.

Thanks and Regards,

Kunal

kbhowmick at 2007-6-29 17:20:51 > top of Java-index,Archived Forums,Swing...
# 3
can you please post some detailled code of what you tried ?I will look back in this part of code to check what i've done.Thanks.Marc
marc_huhardeaux at 2007-6-29 17:20:51 > top of Java-index,Archived Forums,Swing...
# 4
look at this link at mchan0 post, he check the field size, you can check the enter key. http://forum.java.sun.com/thread.jsp?forum=31&thread=227886
noah.w at 2007-6-29 17:20:51 > top of Java-index,Archived Forums,Swing...
# 5
I use the function grabFocus() on the next component. It's the only way i've succeeded in doing this task.Hope this help you .
marc_huhardeaux at 2007-6-29 17:20:51 > top of Java-index,Archived Forums,Swing...