0

I am developing a Java application that uses a JTable. I want to allow the user to enter data in a JTable that can later be printed or saved. The issues is: Suppose the user has entered some data and the cursor is on the last cell of the row in a table (I have uploaded an image-suppose the cursor is on the highlighted cell).How do I make it in such a way that when a user presses the Enter Button(Keyboard button) the application will add/append a new row that is empty to the table so that the user can fill in other data. Attachment

  • Possible duplicate of [How to add row dynamically in JTable](http://stackoverflow.com/questions/22371720/how-to-add-row-dynamically-in-jtable) – Arun Xavier Jan 09 '17 at 06:23

2 Answers2

0

Try this...

  JTable table = new JTable();
  DefaultTableModel tblModel = new DefautlTableModel(0,0);

  table.setModel(tblModel);



  //an action or click then you should run this code


  tblModel.addRow(new Object[]{""}); 
0
    DefaultTableModel tbm = (DefaultTableModel) jTable1.getModel();
    Vector rowData = null;
    tbm.addRow(rowData);
Arpit Porwal
  • 273
  • 3
  • 14