• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable how to unselect a row?  RSS feed

 
Stephen Wei
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all:
How do I unselect a row in a JTable? I do not want to disable the RowSelection mode though.
Does anyone have an easy solution?
Thanks
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
try this:
ListSelectionModel model = table.getSelectionModel();
model.removeSelectionInterval(0,0); //removes the selection of the first line
Hope, this helps.
Rene
 
Stephen Wei
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rene,that is exactly what I want!
I should have read the Java API more carefully though
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!