Hi,
Stuck in this jTable and swing issue. Please help.
My code is as below:
private javax.swing.JTable jTable1;
javax.swing.table.DefaultTableModel model = new javax.swing.table.DefaultTableModel();
jTable1 = new javax.swing.JTable(model);
jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[model.getRowCount()][], new
String[] { "col1", "col2", "col3" }));
model.insertRow(0, new Object [] {"A", "A", "A"});
model.insertRow(0, new Object [] {"B", "B", "B"});
But when i execute this code, the 2 rows added are not getting reflected in jTable. Because in my screen i can only see a table with 3 columns and no rows.
I guess the model object has these rows but its not reflected in jTable1 object.
Also i have to mention rowCount in my setModel method else it gives compilation error ("Variables must be initialized error")
Please tell me how do i mention this count dynamically and reflect on my screen.
Thanks
Archana