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 and the fly likes How to add focus to a cell in a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add focus to a cell in a JTable" Watch "How to add focus to a cell in a JTable" New topic
Author

How to add focus to a cell in a JTable

Padma Prasad
Ranch Hand

Joined: Sep 16, 2002
Posts: 76
Hi all,

How can I add focus to a cell in a JTable? When I add a row in a table, I want the focus to go to the first cell in the row. When I say table.requestFocus(), the first cell of first row is getting the focus. but i want for the newly created row. How can i do this?

Thanks,
Anand.
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
you could try setRowSelectionInterval(newRowIndex, newRowIndex)

D.
Padma Prasad
Ranch Hand

Joined: Sep 16, 2002
Posts: 76
Yeah. When I did this, I am getting the whole row selected. But I want the focus in the first column of the row so that the user can input before he clicks on it. Rather, I want the cursor in the cell and not that the whole row getting highlighted. When I add the row, the first cell should be ready for input. I am using windows look and feel.

Thanks,
Anand.

[ November 09, 2004: Message edited by: Angel Anand ]
[ November 09, 2004: Message edited by: Angel Anand ]
 
GeeCON Prague 2014
 
subject: How to add focus to a cell in a JTable