hi,
I've a bug in the following code, i don't know where it is?? is it in the design itself, or the code needs threading especially in the "Swing". The following code is a part of simple word game that display a word with it's correct meaning among wrong ones, which printed in jLabel object, this object placed on jPanel object which should be greened when the gamer response is correct, otherwise it should become red, after that it moves to the next question (word) and graying the whole jPanel objects again because it's a new question.
Here's the bug if the last line of event handler which graying the panel deactivated, and try to sleep the current thread the greening process happened after not before sleeping.
So, how to coloring the jPanel object and wait for 1 second after that move to the next question and remove the coloring (graying out the jPanel object)
The following code is an event Handler of one jPanel and jLabel object for gamer mouse clicks.
private void mean4LblMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
String lblText = mean4Lbl.getText().toString();
if (lblText.equals(correctMean)) {
this.mean4Panel.setBackground(Color.GREEN);
}
Thread.sleep(1000); //give a chance to gamer to see this result
coordinator(); //move to the next question
this.mean4Panel.setBackground(new Color(236, 233, 216)); //grayed the jPanel object again
}