TopComponent ActionMap InputMap default action on enter key

View: New views
1 Messages — Rating Filter:   Alert me  

TopComponent ActionMap InputMap default action on enter key

by Luc_B :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

I am trying to set a default action when the enter key is pressed.
Here is what I did:

getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "applyFilters");
        getActionMap().put("applyFilters", new AbstractAction() {

            public void actionPerformed(ActionEvent e) {
                System.out.println("apply filters");
            }
        });

This does not work at all. I also tried with different conditions with no success.

Does any one know what I am doing wrong?

Thanks,
Luc