I've seen a post earlier that recommends favoring Actions over listeners. I am not so familiar with the ActionMap. What are the disadvantages of the each approach? I like to make inner classes that implement listeners. Is that a bad practice?
Thanks
Key bindings rely on actions. There is a potential risk that Action
"implementations tend to be more expensive in terms of storage than a typical ActionListener
." In practice, the problem does not arise. Here is an example.
Using KeyListener
is conceptually easier to understand but typically more difficult to maintain. One inevitably ends up re-creating some kind of binding machinery. This example, while instructive and even appropriate for a game, is needlessly complex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With