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.
public void simulateKey(KeyEvent e, Component c) {
Field f = KeyEvent.class.getField("focusManagerIsDispatching");
f.setAccessible(true);
f.set(e, Boolean.TRUE);
c.dispatchEvent(e);
}
Send "Enter" to your JTextField. This was stolen from here.