• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable focus

 
Nathan Daniels
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 634
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nathan Daniels
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nate
Could you let me know how to focus a row in the JTable.
Mohana
 
deepal_mehta
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use setColumnSelectionInterval() & setRowselectionInterval() methods to get focus on your JTable.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic