Package ca.corbett.extras.io
Interface KeyAction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A very simple interface that allows convenient use of lambda expressions for key actions.
This is used by KeyStrokeManager to allow you to specify a lambda for the action to perform when a
keystroke is triggered, without having to create an actual Action class.
Dev note: yes, this is basically just ActionListener, but the overloads for registerHandler() accept Action instances, and the Action class implements ActionListener, which leads to all kinds of confusion with our convenience overloads. So, we use this instead of ActionListener for that purpose, to differentiate them.
The vast majority of the time, this will be used in inline lambdas anyway, like this:
// Much more convenient than creating an Action class for something simple like this:
keyStrokeManager.registerHandler("Esc", e -> dispose()); // dispose on "Escape"
So the fact that this is KeyAction instead of ActionListener is not a big deal.
- Author:
- scorbo2
-
Method Summary
-
Method Details
-
actionPerformed
-