title: How to trigger a JButton with a key press?
body: <p>I'm trying to make it so that when the user presses the Enter key the <code>JButton</code> which is associated with that key gets triggered. </p>
  
  <p>Here's what my code looks like: </p>
  
  <pre><code>import java.awt.event.KeyEvent;
  
  private void formKeyPressed(java.awt.event.KeyEvent evt) {
        if(evt.getKeyCode()==KeyEvent.VK_ENTER) {
            jButton2.setEnabled(true);
     }
  }    
  </code></pre>