aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable focus" Watch "JTable focus" New topic
Author

JTable focus

Nathan Daniels
Greenhorn

Joined: May 03, 2001
Posts: 21
Hi,
I am trying to highlight the first row of a table when the focus is changed to the table. Currently, when I tab from another component to the table, it doesn't highlight the row. Only when I press the arrow down key, the next row gets highlighted. Also, when the focus leaves the table (ie tab out...), I want to remove the highlight from my row. Tabbing from and to the table is working fine. Just need help with the highlighting part. If anyone has done it before or has some ideas on how to get this accomplished, please drop me a line. I would appreciate any feedback.
Thanks,
Nate
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Nathan,
Since you already know how to highlight a table row you can just listen for the FocusLost and FocusGained events and perform what you want there. The Tab movement will trigger those events on the table.
Regards,
Manfred.
Gail Mikels
Ranch Hand

Joined: May 07, 2001
Posts: 634
I have a similar situation, only I need to hilite one of several JTextAreas that are within my JPanel. I can't find how to get the hiliting done. Can you help?
Thanks,
*Gail


Gail Mikels
Nathan Daniels
Greenhorn

Joined: May 03, 2001
Posts: 21
Hi Manfred,
Thanks for your post. I am now able to highlight the first row when I tab into the table and remove the hightlight when the focus is lost.
Gail,
There is a sun tutorial for using the FocusListener which will help you with your problem.
Thanks,
Nate
Anthony Kwok
Greenhorn

Joined: May 09, 2001
Posts: 23
Originally posted by Nathan Daniels:
Hi Manfred,
Thanks for your post. I am now able to highlight the first row when I tab into the table and remove the hightlight when the focus is lost.
Gail,
There is a sun tutorial for using the FocusListener which will help you with your problem.
Thanks,
Nate

Hi, could you post your code for that?
Thanks!
Anthony
mohana konakanchi
Ranch Hand

Joined: May 16, 2001
Posts: 67
Hi Nate
Could you let me know how to focus a row in the JTable.
Mohana
deepal_mehta
Greenhorn

Joined: May 21, 2001
Posts: 5
Use setColumnSelectionInterval() & setRowselectionInterval() methods to get focus on your JTable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable focus