repaint() calls sometimes not being processed
I'm making a turn-based game and was doing a test of a simple AI "dummy" player. I gave it a simple task, just to move the cursor around a bit, open the pause menu, and end its turn. To give the AI turns a bit more "animated" look, I required it to basically go through the same control flow as a human player would, by calling the methods tied to bound keys and telling it to wait for a short period between issuing commands. For example, a human player presses the left key. If he is allowed to move that time, the key's actionPerformed() method calls the leftKey() method. The AI, upon moving the cursor left, also calls the leftKey() method, but doesn't need to verify it, because the program assumes it's the AI turn. The methods for all of these keybindings end in repaint() calls.
This works fine for a human player; the action's made, the JPanel's updated, and everything proceeds normally. However, on the AI player's turn, it seems that the repaint() commands are ignored. When I run the program with myself as player 0 and the AI as player 1, and I end my turn, the JPanel basically "freezes" until the AI's turn is over, then immediately updates when it's my turn again. Looking at the program and some print tests, the AI's doing its job fine - the changes just aren't showing up.
Why is this happening, and what's the best way to fix it? I'd greatly appreciate any help.