hi i had created a Jtable Which Stores Data like below
--------------------------------------------------------
a b c d e
w q 1 2 9
--------------------------------------------------------

i want to get the cell value when i click to the cell... i tried lot but not got hte out put please help to get the output please

use

myTable.getValueAt(selectedRow,selectedColumn);

which returns an Object


hi i had created a Jtable Which Stores Data like below
--------------------------------------------------------
a b c d e
w q 1 2 9
--------------------------------------------------------

i want to get the cell value when i click to the cell... i tried lot but not got hte out put please help to get the output please

thanks for your answer but the selected row and column value is differ for each click

so, your selectedRow would be

myTable.getSelectedRow()

and your selectedColumn would be

myTable.getSelectedColumn()

thanks for your answer but the selected row and column value is differ for each click

Retreiving the data value in cell could be done by creating a class that implements ListSelectionListener and passed it as argument to the ListSelectionModel of the table and to the ListSelectionModel of ColumnModel of the given table.
hope it helps.

this approche will give the value of the cell if you click on or if you use the keyboard button navigaiton.

This article has been dead for over six months. Start a new discussion instead.