Okay, you know when on like an alert window, or a form, one of the buttons automatically gets executed when you press enter, such as shown. See Picture #1

So I was wondering how I could do this in Java for a both a JFrame and a JOptionPane. Thanks.

arithehun

Picture #1

Never mind, I figured it out. In your constructor, post the following code, and replace "buttonName" with the name of a JButton:

getRootPane().setDefaultButton(buttonName);