How do I select a row (or rows) in a JTable?
Created Feb 5, 2000
John Zukowski
In the Model-View-Controller (MVC) world of Swing, the JTable is just a display mechanism. Instead of selecting rows in the table (view), you select rows in the selection model:
ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(start, end);
You can also select multiple blocks of non-contiguous rows, using the addSelectionInterval() method.