• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

on Contrl + Home how to set focuson to first field on the form?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a form.in that on control + home button focus should goto first field on the screen and control+end to last field on the screen.please give solution to this problem? urgent?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
reddy,

Please re-register with a user name that follows the guidelines of the Official JavaRanch User Name Conventions. As to your question, all you'd have to do is add a KeyListener to your JPanel, or whatever holds the fields, and in the keyPressed(KeyEvent) method check for control being pressed with event.isControlDown() and then test the KeyEvent's key code against the key code of the home or end keys ( event.getKeyCode()== KeyEvent.VK_HOME ), and then call requestFocus() on the appropriate field... You should end up with something like this in your KeyListener...



-Nate
 
reply
    Bookmark Topic Watch Topic
  • New Topic