I have a table that includes several columns with check boxes in them. Occasionally, my code needs to remove the columns and create new ones. When I do this via the following code
int columnscount = myTable.getColumnCount();
//remove the columns
for(int i=2;i<columnscount;i++){
myTable.getColumn(2).dispose();
}
All the columns are removed but the checkboxes are not. How do I remove the editor components? They are created using this code
TableEditor editor = new TableEditor (myTable);
editor.minimumWidth = checkButton.getSize().x;
editor.horizontalAlignment = SWT.CENTER;
editor.setEditor(checkButton, ti, colCheckCount);
The proper way of removing a column from Swing’s
JTableis by invokingremoveColumnmethod:table.removeColumn(table.getColumnModel().getColumn(0));Be cautious however, because this only removes the column from view without removing the underlying data.