title: Adding keylistener or key binding to JButtons that use ActionListener
body: <p>i need some help with adding keylistener or key bindings to the buttons from the next example. I want when i press A or B on the keyboard, to make the same action like when i press it with the mouse.</p>
  
  <pre><code>import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  
  public class NetTest {
  
      static JButton btnA = new JButton("A");
      static JButton btnB = new JButton("B");
      static JPanel jp = new JPanel();
      static JFrame jf = new JFrame("Test APP");
      static JLabel jl = new JLabel("Which button was clicked ?");
  
      static ActionListener action = new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              jl.setText(((JButton)e.getSource()).getText());
          }
      };
  
      public static void main(String[] args) {
          jf.setVisible(true);
          jf.setSize(400, 400);
          jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          jp.add(btnA);
          jp.add(btnB);
          jp.add(jl);
          jf.add(jp);
  
          btnA.addActionListener(action);
          btnB.addActionListener(action);
      }
  }
  </code></pre>