Hi
I have a program which constructs 2 objects with AI to play against each other in a card game. Simplified it works more or less it works as below
- a function (functionA) queries object1 to make a move
- object1 decides what it wants to play and it sets a JLabel(a card) in a JPanel
[edit]
in order to set the JLabel a function is called in another class, is this class were to make a callback it would have to be to a static method in the class where functionA is, there is no inheritance between these 2 classes
[/edit]
a repaint() is called but as repaint() only paints when it feels like it the image is not painted.
-the same function then queries object2 to make a move
-object2 decides what it wants to play and it sets a JLabel in a JPanel
object1 is queried once again and the function continues to cycle until there is a winner, however java does not paint anything until this function finally returns (ie a winner has been found).
without rewriting the whole program (i was not expecting this behaviour when i first started to write the program, and when it was just text it worked fine) is there a way i can force a repaint and cause the function to not continue until the label has been painted ?
----------------------------------
Unfortunately i can't set images instead of JLabels because i need functions that JLabel provides. This means (i don't think) i can use imageObserver or mediaTracker.
Also i experimented unsuccessfully with repaint(), i sent it parameters to only repaint the specific area that had changed and to give it a prioty to repaint. ie. repaint(0); where '0' is the number of miliseconds to wait before to repaint().
I've been thinking about this problem for a while now and i can't think of a solution so if anyone can help, i'd be most appreciative
thanks