You could be using a JTable and have faced a problem of trying to insert or add a row to a JTable. well then continue reading forward else rewind and get the message clearly.

Before u get your hands grimy, take this into consideration;

  • Right click on the  Jtable and select Table Contents, Remove all the rows and column.
  • Right click on the  Jtable and select  Change Variable Name.specify a descriptive name you want.
  • import the DefaultTableModel in your source code and try this example out

DefaultTableModel model = new DefaultTableModel();
mytable.setModel(model);
model.addColumn(“Tables”);
int i=0;
try{
while (i<10) {
model.insertRow(i,new Object[]{i});
i++;
}
}
catch(SQLException ex)
{

}

LEAVE A REPLY

Please enter your comment!
Please enter your name here