Search code examples
javaswingtablemodel

Remove blank propertyColumn from swing tableModel


I would like to remove en empty propertyColumn from tableModel. Is there any function which returns its content? Next I should use removeColumn() yes?


Solution

  • Generally you don't remove the data from the TableModel. Typically you would just remove the column from the view of the JTable:

    table.removeColumn( table.getColumn( "..." ) );
    

    The data will still be accessible in from the TableModel.

    If you really want to remove the data then you can use a DefaultTableModel which supports a setColumnCount(...) method. However this will only allow you to remove columns at the end of the model. If you want to remove columns of data in the middle then you need to implement your own custom method.