keyPressed() method not working after mousePressed()

84 Views Asked by At

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 the keyPressed() method of keyListener is not being invoked.I added keyListener, mouseListener and mousesMotionListener to the JFrame and the JFrame is also set to focusable but it is still not being invoked. To be more specific the states are just objects of a state class with different methods inside.

0

There are 0 best solutions below