The boolean values need to be in a place that both the KeyListener and the Timer's ActionListener can access. They could share a model or refer to an outer class as described here: Action Listeners -...
Type: Posts; User: KevinWorkman
The boolean values need to be in a place that both the KeyListener and the Timer's ActionListener can access. They could share a model or refer to an outer class as described here: Action Listeners -...
Wait, you want the rectangle to continue moving even after the user lets go of an arrow key?
If that's the case, then you just need to set the variable once, when the user first presses the key.
...
Keep track of 4 booleans: one for each arrow key.
When the user presses one of the arrow keys, set the corresponding boolean to true.
When the user releases an arrow key, set the corresponding...