Java JTable getting the data of the selected row

ZeroCool picture ZeroCool · Mar 30, 2015 · Viewed 114.6k times · Source

Are there any methods that are used to get the data of the selected row? I just want to simply click a specific row with data on it and click a button that will print the data in the Console.

enter image description here

Answer

ManyQuestions picture ManyQuestions · Mar 30, 2015

http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html

You will find these methods in it:

getValueAt(int row, int column)
getSelectedRow()
getSelectedColumn()

Use a mix of these to achieve your result.