registering KeyEvents on a JComponent
How do I add a key listener to a JComponent? The documentation seems to indicate that KeyListeners can only be on certain kinds of components like JTextArea and the like, bu tIm trying to implement a drawing program and would like ctrl+z functionality, and I need the component all the drawing is happening on to register key events.
Re: registering KeyEvents on a JComponent
never mind, i did more research and apparently the way to go is an input map? is this correct?
Re: registering KeyEvents on a JComponent
Quote:
Originally Posted by
yemista
never mind, i did more research and apparently the way to go is an input map? is this correct?
The following gives a pretty clear demo for how to do this: How to Use Key Bindings (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)