• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JTable focus

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nate
Could you let me know how to focus a row in the JTable.
Mohana
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use setColumnSelectionInterval() & setRowselectionInterval() methods to get focus on your JTable.
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic