title: java key pressed to perform an action
body: <p>i am very new to java.I am developing a inventory management system where i want to add the data to the jtable when "ENTER" key  is pressed.but i don't know how to do so.i have searched about key bindings but got nothing helpful for me at that initial stage.here is my action that i want to perform at key pressed..</p>
  
  <pre><code> private void addItemActionPerformed(java.awt.event.ActionEvent evt) {                                        
     int quantity,price;
     Product p=new Product();
     String[] result=new String[8];
     String data[]=new String[6];
     int i=0;
     result=p.getInfo(this.addItemField.getText());
      for(String s:result){
          data[i]=s;
          i+=1;
      }
      data[0]="1";
      quantity=Integer.parseInt(data[0]);
      price=Integer.parseInt(data[5]);
      int tPrice=price*quantity;
      data[5]=Integer.toString(tPrice);
      System.out.println(quantity+" "+price);
      table.addRow(data);
      this.addItemField.grabFocus();
    } 
  </code></pre>
  
  <p>and here is my default constructor</p>
  
  <pre><code>    public SellWindow() {
  
      initComponents();
      String title[]={"Qty","Code","Name","Unit Value","ml/kg","Line Total","Action"};
      entry.getColumnModel().getColumn(0).setPreferredWidth(20);
      table.setColumnIdentifiers(title);
      this.entry.setModel(table);
  
  }
  </code></pre>