So I have a Submit button with an ActionEvent
that consists of around 50 lines of code. How would I assign the exact same ActionEvent
for the JFrame
as the Submit button whenever it detects the Enter key being pressed? This is what my Submit button's ActionEvent
looks like
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// miscellaneous code that needs to be repeated for 'Enter' key press
}
});
What and where would the code for giving the JFrame the same ActionEvent
as the Submit button go?