Question

I currently have a problem whereby editing the contents of one cell in a JTable alters the content of another; two of the columns are mutually exclusive. They are both checkboxes.

At the moment, if I alter one cell, it isn't until the other is redrawn that it updates. Therefore, both cells in the row can be displayed as being selected at any one time. This can be overcome by calling updateUI(), but it is slow and not a generally great idea.

Has anyone got any tips or suggestions?

Was it helpful?

Solution

It sounds like you should be using a TableModelListener to listen for changes to the TableModel. When a checkbox is changed you will receive an update event and you would then update the other checkbox by using model.setValueAt(...). The model is responsible for notifying the view to repaint the cell.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top