How to make a columns in JTable Invisible for Swing Java

前端 未结 8 1449
半阙折子戏
半阙折子戏 2020-12-03 04:44

I have designed one GUI in which I have used one JTable from which I have to make 2 columns invisible . How should I do that ?

8条回答
  •  遥遥无期
    2020-12-03 05:02

    Remove the TableColumn from the TableColumnModel.

    TableColumnModel tcm = table.getColumnModel();
    tcm.removeColumn( tcm.getColumn(...) );
    

    If you need access to the data then you use table.getModel().getValueAt(...).

    For a more complex solution that allows the user to hide/show columns as they wish check out the Table Column Manager.

提交回复
热议问题