0

The title says it all. I don't know how to uncheck the checkboxes on the Jtable after a Jbutton is clicked. I tried

   JCheckBox renderer = (JCheckBox)table.getDefaultRenderer(Boolean.class);
   renderer.isSelected(false);

but it doesn't work.

Saoirse
  • 3
  • 3
  • 2
    Iterate through each row of the JTable, find the checkBox and change the selection. Some rough code might look something like this: `for (Row row : rows) {row.getCheckBox().setState(false);}` – sorifiend Nov 26 '20 at 03:46
  • 2
    A complete example is examined [here](https://stackoverflow.com/a/4528604/230513) and a related example is examined [here](https://stackoverflow.com/a/7137801/230513). – trashgod Nov 26 '20 at 03:48
  • 2
    This has nothing to do with the renderer. You change the data in the TableModel to Boolean.FALSE for each row by using the setValueAt(...) method of the JTable. The table will then repaint itself and the the renderer will render the data. – camickr Nov 26 '20 at 04:02
  • 2
    @sorifiend, . That is not how rendering works. You don't set the state of a check box via the renderer. A renderer is used to render the data. So you need to change the data in the model. – camickr Nov 26 '20 at 04:08

0 Answers0