I have a few different input textboxes which you can enter a command into, press enter, and then it pulls up some information. I have a few different textboxes who (applying to different parts of information). When I press enter, it also moves the focus onto the next input box. How do I stop this? I can’t simply use the consume() method in the keyevent class since that would entirely block the enter key, which is not what I want
Share
Actually, I just found out how to fix this issue. I used the method belonging to Container called requestFocus() (see http://www.javaworld.com/javaworld/jw-07-1998/jw-07-swing-focus.html). In each element I added this line to the end of the keyEvent action and it worked perfectly!