Please tell me what i did wrong
  • To start with you didn't post the code in code tags so it's now difficult to read which means I won't do anything other than give it a cursory glance.
  • You shouldn't be trying to draw on, add KeyListeners to etc a JFrame, you should be using a JComponent such as a JPanel, which you add to the JFrame.
  • When handling the drawing yourself you shouldn't override the paint method, you should override the paintComponent method instead - read the Java tutorial on 2D graphics