redfox26
redfox26

Reputation: 2070

deselect header checkbox when a checkbox is unchecked

i have a jtable with a checkbox in the header and other checkbox in the cell of the column.

like you can see on the picture, there are a problem enter image description here

boolean is used for the first colum for the DefaultTableModel

right now, i have a tableRenderer for my first column

what option should i use to make header to get deselected if a check box is deselected?

thanks

Upvotes: 1

Views: 3282

Answers (2)

Elvis
Elvis

Reputation: 857

That would be very easy. Register a listener to the table model:

table.getModel().addTableModelListener(listener);

Look at the event, if the value changed was from the first column and it was set to false then deselect the checkbox.

Upvotes: 0

Balanivash
Balanivash

Reputation: 6867

Have an actionevent for the top checkbox, and on checked or unchecked, run a for loop to check/uncheck all the checkboxes in the table.

Upvotes: 1

Related Questions