• 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

Keys for JButtons

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All!
I have a JButton. How can I assign an "F2" key form the KeyBoard?
(Not "alt + F2" but "F2" only).
Thanks in advance
Veri.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does setMnemonic() work? If not, I'd think you'd have to make a Component that has focus at all times (i.e. top level frame) a key listener, listen for F2 and send an ActionEvent to the button when that key is hit.
 
Veri Strora
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank's Joe.
setMnemonik() work well, but setMnemonik() method make available alt + F2 and not F2.
Thank You!
 
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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nate,
I bet you have hundreds of these little programs like this from helping people out on javaranch.
Have you ever thought about putting together a type of SWING FAQ and for each Question, you have one of these little programs?
I know we could just search the SWING forum, but knowing a search is returning some code instead of filtering through all the garbage might be nice...
I think it would be neat and very useful. Maybe even write a book. Then you could get that Author status.
 
Veri Strora
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You very mutch Nathan!
Very Good Example.
reply
    Bookmark Topic Watch Topic
  • New Topic