• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to solve JTable.getValueAt() problem in case of AbstractTableModel?  RSS feed

 
vijay Panner
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing an application using java swing. Here I retrieve data from database and show data on JTable by using AbstractTableModel. After got data in JTable, I have selected a row , it returns row no=-1.
Please help me to solve this problem.

Actually I am getting row no =-1 in table.getSelectedRow().

Thanks
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, why do you use AbstractTableModel? Why not DefaultTableModel?

To get better help sooner, post a SSCCE that clearly demonstrates your problem.

Don't forget to use the code tags so your code retains its formatting.
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Row selection has nothing to do with the TableModel, so it doesn't matter if it's an AbstractTableModel or DefaultTableModel. It's the JTable's ListSelectionModel that handles the selection.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!