the game:
declare variables
make a buffer
load stuff
run as long as it makes sense
clear the buffer (or don't)
change variables accordingly to the input flags (logic)
draw the background on the buffer
draw the sprites on the buffer
draw the hero on the buffer (using those variables)
draw other stuff on the buffer
draw the buffer on the screen
repeat
---
in the input handler:
if key 'x' is down set the flag to 1
if key 'x' in not down set the flag to 0
if key 'esc' is down set "makes sense" to false

---
That's the whole idea. Of course you need to know how to programm in java - otherwise you won't be able to do much.