Hi everyone! I need some help
I have a jTable that uses a model for handling data
Then, in another class, depending of the class, I erase all the content of the model (and the columns)tableModel = new DefaultTableModel();
jTable1.setModel(tableModel);
When it comes to fill the table, I create the identifiers or columns and insert row by rowpublic static void clearDefaultTableModel(DefaultTableModel tableModel) {
tableModel.setRowCount(0);
for (int i = 0; i < tableModel.getRowCount(); i++) {
tableModel.removeRow(i);
}
String[] vector = null;
tableModel.setColumnIdentifiers(vector);
}
What I need is put the jTable not editable (I already changed the seteditable property of the table) and most important, when its time to recreate the model, put differents widths to each column (I dont want the ID column with the same width as the name column)Object[] columnNames = {"header 1","header 2","header 3"};
tableModel.setColumnIdentifiers(columnNames);
....
String[] vector = {string1,string2,string3};
tableModel.addRow(vector);
Hope you can help me, tables and models are confusing me.