• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Q on JTable -- GUI

 
Reshma Das
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i programatically select a row ?
i dont find any method in api. can someone suggest me one ?
Assume a condition where there are 5 seats remaining for FlightA.
Client A books 4 seats
client B books 2 seats.
client A succeeds. client B gets error msg saying 'Check the seats'.
To do that the data should be refreshed and the selected flight no should be highlighted.
i refreshed the table but i dont know how to select the row from JTable.
pls help.
 
Rajesh Matti
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, you may use JTable.setRowSelectionInterval() to do so.
A better addition would be to select and make the row visible in the viewport. Following code explains how to achieve this.
JTable.scrollRectToVisible(JTable.getCellRect(rowToSelect,0,true));
JTable.setRowSelectionInterval(rowToSelect, rowToSelect);
Hope this helps.
-Rajesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic