Removing a column with table editor components

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);

Answers


The proper way of removing a column from Swing's JTable is by invoking removeColumn method:

table.removeColumn(table.getColumnModel().getColumn(0));

Be cautious however, because this only removes the column from view without removing the underlying data.


Need Your Help

Fork jQuery to fork one of its built-in components as a plugin?

jquery jquery-plugins github forking

I want to make my own enhanced spin-off of one of the jQuery "helper" functions as a plugin (deferred.js/$.when() as it happens.)