File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes JTable: disable Pre selected row Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "JTable: disable Pre selected row" Watch "JTable: disable Pre selected row" New topic
Author

JTable: disable Pre selected row

Mansoor Akhtar
Greenhorn

Joined: Jul 11, 2010
Posts: 12
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
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17259

What happens if you clear the selection? There is a nice method for that in JTable.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Mansoor Akhtar
Greenhorn

Joined: Jul 11, 2010
Posts: 12
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

Joined: Jun 13, 2009
Posts: 1644
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.

This message was edited 1 time. Last update was at by Rob Camick

 
 
subject: JTable: disable Pre selected row
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com