I am working on a Java project and need to have a keypress simulate a click on a JTextField. What I\'m looking for is the equivalent of the JButton doClick() method.
What I want is when the user presses enter, it calls the same code as when they click anywhere in the frame
Still doesn't make sense to me.
When the user clicks any where on the frame a couple of things happen:
a) the text field loses focus
b) some other component gains focus
You could add an ActionListener to the text field. The ActionListener is invoked when the Enter key is pressed. But then how to you guess where on the frame to generate a mouse click? Seems like random logic to me.