aspose file tools
The moose likes Swing / AWT / SWT and the fly likes How to use ListSelectionListener in Jtable? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "How to use ListSelectionListener in Jtable?" Watch "How to use ListSelectionListener in Jtable?" New topic
Author

How to use ListSelectionListener in Jtable?

vignesh karthick
Ranch Hand

Joined: Mar 16, 2008
Posts: 32

Hi all,
Can anyone tell me, how to use ListSelectionListener in jtable to get row values and store it an database?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 1788
    
    2
I'm not sure I understand the question.

It seems like you want to get the values of a selected row and copy them to a database. If this is the case then you would not want to use a ListSelectionListener. This event fires every time you click on a row or use the arrow keys to move up/down in the table.

Instead I would suggest you need a button like "Update Database". Then you can use the table.getSelectedRows() method to get the index of all selected rows. Then you can loop through the array and access the data in each row by using the getValueAt(...) method for each row and for every column in the row.

But if you really want to use a ListSelectionListener then you can read the Section from the Swing tutorial on How to Write a List Selection Listener for an example.
vignesh karthick
Ranch Hand

Joined: Mar 16, 2008
Posts: 32

Thanks Mr.Rob Camick. This is the exact solution that i need.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to use ListSelectionListener in Jtable?
 
Similar Threads
How to use ListSelectionListener in Jtable?
jtable
getValueAt in JTable
Binding a JTable column to a bound combobox
ListSelectionListener in JTable