I'm currently coding a find-match game (a kind of memory game). I've
coded in C# but not
yet with Java. I'm working on it but I've a problem as follows;
In the beginning, all pictures are closed. When one of my pictures is
clicked, it will be
opened. Then when second is clicked it will be compared with first. If
first and second is
same, they will be remained opened but when they aren't same, the
second and first will be
shown 1 second then both of them will be closed. I've coded it but I
have some problems
about threading. When I click second (an image that is diffent from
first clicked) they both
are suddenly closed. Second can't be seen. But I want the diffent two-
images remains in
screen for 1 seconds. For this, I wrote a Thread.Sleep(1000); but it
doesn't work. It waits
while second-clicked is still closed. Second can't be seen. I wrote a
Application.doEvents() before Sleep(1000) then Sleep(1000) in c# and
it worked but I don't know how to do Application.doEvents() in Java.
(If I don't write Application.doEvents() in my C# code, It works like
my java program as you might understand...)
Thanks.
Lew - 07 Mar 2007 21:42 GMT
> I wrote a
> Application.doEvents() before Sleep(1000) then Sleep(1000) in c# and
> it worked but I don't know how to do Application.doEvents() in Java.
> (If I don't write Application.doEvents() in my C# code, It works like
> my java program as you might understand...)
What does Application.doEvents() do?
-- Lew
Dag Sunde - 07 Mar 2007 22:03 GMT
>> I wrote a
>> Application.doEvents() before Sleep(1000) then Sleep(1000) in c# and
[quoted text clipped - 5 lines]
>
> -- Lew
If it is anything like VB, it let the application's internal "messagepump"
thru
for a while. Letting queued-up events run before continuing.

Signature
Dag.
Lew - 07 Mar 2007 23:01 GMT
OziRus wrote:
>>> I wrote a
>>> Application.doEvents() before Sleep(1000) then Sleep(1000) in c# and
>>> it worked but I don't know how to do Application.doEvents() in Java.
>>> (If I don't write Application.doEvents() in my C# code, It works like
>>> my java program as you might understand...)
Lew wrote:
>> What does Application.doEvents() do?
> If it is anything like VB, it let the application's internal "messagepump"
> thru
> for a while. Letting queued-up events run before continuing.
I am not aware of anything like that in Java.
OTOH, the original problem can probably be solved with a little rethink around
the 'synchronized' keyword.
Could be the solution wouldn't even need a Thread.sleep().
-- Lew
Daniel Pitts - 08 Mar 2007 00:29 GMT
> I'm currently coding a find-match game (a kind of memory game). I've
> coded in C# but not
[quoted text clipped - 21 lines]
>
> Thanks.
Instead...
You're "clicked" event will be fired. That triggers the showing of the
image.. You set a Timer for 1000 ms, and the Timer fires an event
which hides the image.