• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable: disable Pre selected row

 
Mansoor Akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,

When a JTable is get displayed, it (automatically) pre-selects the top row (if setRowSelectionAllowed() is not set to false).
I need to have row selection enabled, but i want NO pre-selected row when the table is first displayed.

Thanks in advance.
 
Rob Spoor
Sheriff
Posts: 20821
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you clear the selection? There is a nice method for that in JTable.
 
Mansoor Akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I load the data in to JTable while it is not displayed yet. After loading the data I do call clearSelection(). But when the table gets displayed, the top row is still selected/highlighted.
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never noticed this problem. I don't see this behaviour in the demo from the Swing tutorial on How to Use Tables.

Post your SSCCE that demonstrates the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!