tags:

views:

44

answers:

1

I am in a situation where i have a class, ActionFactory that produces ActionListener s to be used in menu items and buttons. Now i want to bind some of these actions to keys.


    KeyStroke controlS = KeyStroke.getKeyStroke
        (KeyEvent.VK_S,modifierKey,false);
    panel.getInputMap
        (JComponent.WHEN_IN_FOCUSED_WINDOW).put(controlS, "CTRL_S");
    panel.getActionMap().put
        ("CTRL_S", ActionFactory.getAction1());

But action map expects a AbstractAction, now is there a way to use ActionListener in this situation, i would no want to create duplicate functions that return AbstractAction instead just for this.

+1  A: 

The simplest way out I can see is: change your ActionFactory, let it creates Actions instead of ActionListeners.

Roman