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: 
Action handling of `JTable` happens in `javax.swing.plaf.basic.BasicTableUI`. In your case, you probably need to register a new action for `SCROLL_DOWN_CHANGE_SELECTION`. In the action, check whether the current selection == last row of the table.

If that doesn't work, set a breakpoint in `javax.swing.plaf.basic.BasicTableUI.Actions.actionPerformed(ActionEvent)` to see which action is really executed.
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

```