Question: I have a jTable which currently displays and allows editing of a database table, I am now trying to sort adding tuples. 

I am trying to get it to automatically add a row on downarrow at the bottom. So if I am at the bottom on the table and click my down arrow a new row will appear below. I just can't figure out how to do it.

Thanks
James

Answer: 
JTable has a default Action for the down arrow key. If you want to change this behaviour then you need to create a custom Action. You can do this easily by using the [Wrapping Actions](http://tips4java.wordpress.com/2008/11/03/wrapping-actions/) concept to leverage the default code.

You can also look at [Table Tabbing](http://tips4java.wordpress.com/2008/11/04/table-tabbing/) for a working example of wrapping an Action. You code for the Action would be much simpler and would be something like:

```
if (last row is selected)
    add a new row to the table

invoke the default down arrow action

```
You'll need to create a KeyListener and add this to your table:

```
public void keyReleased(KeyEvent e) {
  int keyCode = e.getKeyCode();
  if (keyCode == KeyEvent.VK_DOWN)
        // check if selected table row = last row and if so: add new row to table model
}

```

greetz,  

Stijn