• 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

Hot key doesn't work?

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to make the user feel covenient to use the UI, I try to make the VK_ENTER as the hot key of ok button.
I've tried the three way to do it.

add the key listener to JFrame - doesn't work

overide processKeyEvent method --- doesn't work

add key listener to every focusable component -- work, but cumbersome. I want to know whether the 3rd one is the only solution? and how to fire the action? do I need to let it invoke the same method of ButtonListener? I wonder there's something like the onclick method...
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Zee Ho,

You might try to use instead (in your frame/dialog's scope).

Hope that helps,
 
reply
    Bookmark Topic Watch Topic
  • New Topic