What is the difference between registerKeyboardAction (...) and getInputMap (). Put (...) + getActionMap (). Put (...)?

What is the difference between these two ways:

getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke( "pressed F10"), "someAction"); getActionMap().put("someAction", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { //Do something } }); 

and

 registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //Do something } }, KeyStroke.getKeyStroke("pressed F10"), JComponent.WHEN_FOCUSED); 
+4
source share
1 answer

There is no difference, but registerKeyboardAction is deprecated as stated in javadoc.

+2
source

Source: https://habr.com/ru/post/1501069/


All Articles