Hello, I have a slight problem in my
java swing application. I've created a JButton and added an actionListener to it within the constructor like this.
//action listener for button2
button2.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e) {
do something
}//end method actionPerformed
});
//end of actionlistener for button1
Now, the problem I'm facing is that, I want to make the ENTER button on the keyboard to have the same effect as the button, button2. How do I do this without having to rewrite the entire actionPerformed method. It's actually quite long. Such that if the user presses button2 or presses enter, it has the same effect. Thanks.