• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using ActionMap for HotKey mapping

 
Sai Prasad
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.
 
Adam Roberts
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...
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac 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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic