how to add checkbox and combobox in table cell?

后端 未结 2 2204
独厮守ぢ
独厮守ぢ 2020-12-03 16:13

I am creating one form which contain table and some buttons.

A picture is worth a thousand words:

\"ente

2条回答
  •  一个人的身影
    2020-12-03 17:13

    includeColumn.setCellEditor(new DefaultCellEditor(new JCheckBox()));
    
    • there no reason to use or write Renderer and Editor for JCheckBox in the JTable, put there true / false, because JTable has built_in support for JCheckbox as Renderer and Editor too

    • override proper column, returns Boolean.Class

    • for JComboBox to read Using a Combo Box as an Editor

    • every data are stored in XxxTableModel, and by using DefaultTableModel are events automatically displayed in the JTables view

    • all updates to the XxxTableModel must be done on Event Dispatch Thread

提交回复
热议问题