NiceButDim
Programmer
I am having a problem related to the update method. In my applet users can select a box from a grid I have drawn. When they select a box I draw the box in red, that part is okay. When the user selects a second box, I want to clear the first and ‘select’ the second. This is where my problem lies.
My code basically say;
If(boxAlreadyDrawn == true) {
drawingMode = CLEAR_BOX;
repaint();
}
boxAlreadyDrawn = true;
drawingMode = DRAW_BOX;
repaint();
Within my Update method I check the value of the ‘drawingMode’ variable and clear or draw a box accordingly. What I am encountering is that within the Update method the variable drawingMode is never set to ‘CLEAR_BOX’. When I expect it to be ‘CLEAR_BOX’ it is instead set to ‘DRAW_BOX’.
If I comment out the last 3 lines of the above code then I do see ‘CLEAR_BOX’ coming through. I assume from this that the program isn’t waiting for the update method to complete before moving on with the next line of code in the calling method. Is this correct? and if so, is there anything I can do about it?
Thanks.
My code basically say;
If(boxAlreadyDrawn == true) {
drawingMode = CLEAR_BOX;
repaint();
}
boxAlreadyDrawn = true;
drawingMode = DRAW_BOX;
repaint();
Within my Update method I check the value of the ‘drawingMode’ variable and clear or draw a box accordingly. What I am encountering is that within the Update method the variable drawingMode is never set to ‘CLEAR_BOX’. When I expect it to be ‘CLEAR_BOX’ it is instead set to ‘DRAW_BOX’.
If I comment out the last 3 lines of the above code then I do see ‘CLEAR_BOX’ coming through. I assume from this that the program isn’t waiting for the update method to complete before moving on with the next line of code in the calling method. Is this correct? and if so, is there anything I can do about it?
Thanks.