How do I make a rectangle move across the screen with key bindings?
You should override paintComponent in your JPanel and call super.paintComponent(g) in it. See How to Use Key Bindings tutorial. Key bindings are preffered in this case rather than a KeyListener pack() then setVisible() You should set global variables for x anf y location, so they can be accessed from within your Action. Then in your … Read more