DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);
// Create a couple of columns
model.addColumn("Col1");
model.addColumn("Col2");
// Append a row
model.addRow(new Object[]{"v1", "v2"});
The TableModel behind the JTable handles all of the data behind the table. In order to add and remove rows from a table, you need to use a DefaultTableModel
To create the table with this model:
JTable table = new JTable(new DefaultTableModel(new Object[]{"Column1", "Column2"}));
DefaultTableModel model = (DefaultTableModel) MyJTable.getModel();
Vector row = new Vector();
row.add("Enter data to column 1");
row.add("Enter data to column 2");
row.add("Enter data to column 3");
model.addRow(row);
get the model with DefaultTableModel modelName = (DefaultTableModel) JTabelName.getModel();
Create a Vector with Vector vectorName = new Vector();
add so many row.add as comumns
add soon just add it with modelName.addRow(Vector name);