I have no idea what to do. I am creating an application. I need to work with the table, so I use JTable. But I have a lot of problems with this. This seems to work, but when I try to delete a column, that column disappears (only in the GUI), but all the information still exists. Also columncount does not change.
I searched and tried many different codes, but nothing has changed.
public void addTblCol(JTable table,String name) {
DefaultTableModel model = (DefaultTableModel)table.getModel();
TableColumn col = new TableColumn(model.getColumnCount());
col.setHeaderValue(name);
table.addColumn(col);
model.addColumn(name);
this.realColCnt++;
};
public void delTblCol(JTable table,int index) {
DefaultTableModel model = (DefaultTableModel)table.getModel();
TableColumn col = table.getColumnModel().getColumn(index);
table.removeColumn(col);
table.revalidate();
this.realColCnt--;
};
CROSP source
share