text: I need help with making an image of a spaceship move when I press an arrow key. For now, all I want to do is make the spaceship image move to the right when I press the right arrow key. Here's part of my code that I think could be the problem:
  Code Java:
  public void paintComponent(Graphics g){ super.paint(g); g.drawImage(starfield,0,5,null); g.drawImage(spaceship,shipx,shipy,null); } public class Keyboard implements KeyListener{ public void keyTyped(KeyEvent event){} public void keyPressed(KeyEvent event){ if(event.getKeyCode()==KeyEvent.VK_RIGHT){ shipx++; repaint(); } } public void keyReleased(KeyEvent event){} }
  When I compile the above code in JCreator, there are no errors. It's just that the image of the spaceship doesn't move at all. I found many of examples online, but they were too complicated for me to follow. All help is greatly appreciated.