• 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

Using ActionMap for HotKey mapping

 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone used ActionMap, InputMap and KeyStroke classes to map key strokes to gui actions and passed the exam??! I am not sure if Sun considers this design is something that a junior programmer can't understand.
As always, your opinions are greatly appreciated.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. Ive never used it. Not like you really need to though. Its not like the GUI is complex(at least mine isn't). Two whole buttons on mine.

I suppose it would be a good thing to know though
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code is not that hard. You just have to get the details ironed out. Below is the method defined in my search panel class, I use for KeyStroke mapping:

In my search panel controller, the inner class extends AbstractAction instead of implementing ActionInterface.

Mark is going to definitely say it is a overkill. Is it true Mark? I don't want to fail...please...
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's see I had 4 ActionListeners, 1 Focus Listener, and 1 ListSelectionListener
The FocusListener is just like your ActionMap and only took me 1 line of code that is using the basic Action/Listener pattern in java which every Junior programmer learns in the beginning.

But yours is not overkill. , and I mean that.
Mark
 
The moustache of a titan! The ad of a flea:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic