I need to undo all selections in a JTable model object. Java provides this "clearSelection ()" function, which does what I need, as far as I understand.
But I am confused why this function can be called in the JTable object, as well as in the selection model for the JTable object:
1) mytable.clearSelection(); 2) mytable.getSelectionModel().clearSelection();
Both methods work, but I donβt understand in what situation clearSelection () SelectionModel (e.g. 2)) makes sense. As far as I understand SelectionModels, they use to decide which choices JTable allows. I use SelectionModel to allow selection of only one row
How should be preferred in which situation? Is there a good reason not to use method 1?
I would be glad if someone had a friendly explanation for this. thanks in advance.
source share