title: JTable enter key actions
body: <p>I am developing an application using <code>JTable</code> for inventory management.</p>
  
  <p>The action is, by typing the item code in a <code>JTextField</code> and by pressing enter key, the details of that code should come to <code>JTable</code>. And there I have to type the quantity and press enter to calculate the amount. </p>
  
  <p>But now by giving item code the details come to the <code>JTable</code>, and I can type the quantity, but there by pressing enter key <code>JTable</code> focus goes to the next row and no calculation is being done.  I am using MySQL and Java in Netbeans.</p>
  
  <p>I found some code.  This code you given earlier for this problem</p>
  
  <pre><code>private void createKeybindings(JTable table) {
      table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
      table.getActionMap().put("Enter", new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent ae) {
  
          }
      });
  }
  </code></pre>
  
  <p>But I have no clear idea about this code.</p>
  
  <ul>
  <li>Please explain where to add this code or there are any other codes to do this.</li>
  <li>Please tell me step by step where i put this code in Netbeans IDE (I follow this link <a href="https://web.archive.org/web/20120626114430/http://java.sun.com/products/jfc/tsc/special_report/kestrel/keybindings.html" rel="nofollow">https://web.archive.org/web/20120626114430/http://java.sun.com/products/jfc/tsc/special_report/kestrel/keybindings.html</a>, but I can't understand it).</li>
  </ul>
  
  <p>Thank you...</p>