我有JTable
和JComboBox
。當我在組合框中選擇一個項目時,我想要隱藏某些列,當我選擇組合框中的其他項目時,隱藏的列將重新出現。我寫的,如何根據JComboBox中的選擇顯示/隱藏某些JTable列
jTable1.getColumnModel().getColumn(8).setMinWidth(0)
jTable1.getColumnModel().getColumn(8).setMaxWidth(0)
jTable1.getColumnModel().getColumn(8).setWidth(0)
隱藏列,但是當我再次寫
jTable1.getColumnModel().getColumn(8).setMinWidth(100)
jTable1.getColumnModel().getColumn(8).setMaxWidth(100)
jTable1.getColumnModel().getColumn(8).setWidth(100)
隱藏列不可見。
另請參閱此[相關示例](http://stackoverflow.com/a/10089138/230513)。 – trashgod
但在上面的代碼中有什麼問題? – user1760166