table.setCellSelectionEnabled(true);
To allow cell selections. The adding a ListSelectionListener to the SelectionModel will only fire upon row selection. If you add a ListSelectionListener on...
Type: Posts; User: copeg
table.setCellSelectionEnabled(true);
To allow cell selections. The adding a ListSelectionListener to the SelectionModel will only fire upon row selection. If you add a ListSelectionListener on...
First tip: when you call getSelectedRow() on a JTable, its always good practice to make sure it does not return -1 (if nothing is returned), otherwise when your code continues an exception may be...
If you just need to listen for selection events, register a ListSelectionListener on the table's selection model.
Doh! Thanks for the correction. My brain is running on low today
Tables aren't extremely intuitive until you start using them quite a bit.
You may wish to change your model TableMode to avoid naming conflictsl, since (indirectly) it is implementing TableModel.
...
Create a custom TableModel (extend AbstractTableModel or DefaultTableModel) and set the table model to this custom model. Using the custom model will allow you to change the table quite dynamically...