Java Swing: Show pressed button when using corresponding keyboard button
I'm making a program in Java, using Swing, with a GUI that contains arrow keys. The arrow keys correspond to the arrow keys on the keyboard. When I press the up arrow key on the keyboard, I'd like the up arrow key on the GUI to show up as being pressed. Until I release the arrow key, it should show it is still being pressed, and when released it should also release. A snippet of my code so far (only for the Up button), which I think is totally wrong in the show being pressed category: ... if (e.getKeyCode() == KeyEvent.VK_UP) { actionArrowUp(); JButton buttonUp = (JButton) mainTab.getComponent