Hi guys first post.
ill try and explain this with pseudo code but will recreate the problem in actual code if i cant explain it very well.
this is just for a simple game im making.
baiscly i want this to happen
- user clicks on the screen.
- the screen then updates.
- waits one second
- then updates the screen again.
i think what happens when i implement this is the repaint requests get combined on the event dispatch thread and dont update the way it i thought when i wrote the code. but im not sure.
let me try some pseudo code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| boolean background = false; boolean square = false
paintScreen() {
if (background == true) { paint the screen blue } else { paint the screen green }
is (square == true) { paint a square }
}
clickOnScreenEvent() {
square = !square;
paintScreen();
pauseProgram('1 second');
background = !background;
paintScreen();
}
} |
that's basically what my program dose
the logic to me seems fine but it doesn't work. basically you never see the square get painted. it just changes the background.
also i use Thread.sleep(1000); which im pretty sure locks up the EDT so yeah how would i go about implementing this in java ?