How do I select a row (or rows) in a JTable?

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.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact