hi
everybody.
i have created a JTable, and now i want to get the data of a particular selected row.
i want to store that data in a string or an array.
i have tried with ListSelectionListener where currently i am getting only the index of the row selected. but how to get the data of that row.
the following is my code for ListSelectionListener
if (ALLOW_ROW_SELECTION)
{
// true by default
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
//Ignore extra messages.
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty())
{
System.out.println("No rows are selected.");
}
else
{
int selectedRow = lsm.getMinSelectionIndex();
System.out.println("Row " + selectedRow + " is now selected.");
}
}
});
}