I'm writing a Java program that will ultimately target an embedded system.
The embedded system will have a physical keypad
Pressing a button
on the physical keypad creates an interrupt which runs the interrupt code which can do... whatever would be appropriate for it to do. (It provides a different number for each keypad button, so we can tell which keypad button was pressed.) Currently I'm writing the emulation code that emulates this keypad.
I'm not sure if I should be generating a KeyEvent
, or an ActionEvent
, or some other sort of event.
I have a window (JFrame) that emulates the keypad, showing buttons for each key on the keypad.
I have another window (another JFrame) which is the view. This window should react to the keypad buttons in the other window. I expect this view window
will have some sort of listener listening for keypad button pressed events.
To further complicate, it would be nice if the emulation program would also respond to the computer keyboard; e.g. the keypad
emulation window has Up, Down, Left, Right arrow keys
, so pressing the arrow keys on the computer keyboard
should do the same thing as clicking the arrow button in the keypad emulation window.
To further confuse, I just realized there are two different ActionEvents
I'm not using javafx.
So my questions are
what sort of "event" should my keypad emulation window generate?
How can my View Window subscribe to these events?
knows nothing about View
, and View
knows nothing about details of Keypad
. Probably a Controller
knows about both of them and connects them together.)
How can I get the Computer Keyboard Arrow Keys to also effect the same result as the arrow key buttons in the Keypad Emulation Window?
Can you provide a simple example?