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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.