Firstly, actionPerformed
is triggerd by an action event, typically on most systems, this is triggered by the Enter key (with context to the JTextField
)...so you don't need to check for it.
Secondly, the source
of the ActionEvent
is typically the control that triggered it, that would be the JTextField
in this case.
Thirdly, String
comparison in Java is done via the String#equals
method...
if ("Enter presses".equals(someOtherString)) {...