• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Using ActionMap for HotKey mapping

 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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
 
I will suppress my every urge. But not this shameless plug:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic