I am trying to make a GUI program that switches states when mouse is clicked and moves a BufferedImage when the corresponding keys are pressed. But when the states are switched