2
table.setRowSelectionInterval(0, 0);

I had tried the above code, but when I use this code I cannot retrieve the values using the below code:

int col = table.getSelectedColumn();
int row = table.getSelectedRow();
finalOID=(String)table.getModel().getValueAt(row, col);
System.out.println("first oid:"+finalOID);

How can I solve this?

Cajunluke
  • 3,103
  • 28
  • 28
Nikhil
  • 2,857
  • 9
  • 34
  • 58

1 Answers1

9

have look at method for JTable

table.changeSelection(0, 0, false, false);

depends of Selection Mode

method must be invoked on Event Dispatch Thread, more in the Oracle tutorial Concurency in Swing

mKorbel
  • 109,525
  • 20
  • 134
  • 319