AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Stopping for a sec to show a Graphical progress.

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
San
Guest





PostPosted: Thu Nov 18, 2004 9:43 pm    Post subject: Stopping for a sec to show a Graphical progress. Reply with quote



Hi, I'm programming Risk, which is a board game, in Java as my homework.
My problem is that when computer plays the game, the program halts for 2
to 5 seconds and show only the final result. What I want to see is that
the program shows every single moves of computer play. So, what I tried
to do is using interrupt and run methods like
Thread.currentThread().interrupt() and Thread.currentThread().run().
This method showed the progress of the computer play, but generates many
exceptions. And, I think the cause of the exceptions is that the program
runs asynchronously. What should I do? Java GUI experts help me~!
Back to top
John McGrath
Guest





PostPosted: Fri Nov 19, 2004 4:20 am    Post subject: Re: Stopping for a sec to show a Graphical progress. Reply with quote



On 11/18/2004 at 4:43:37 PM, San wrote:

Quote:
What I want to see is that the program shows every single moves
of computer play.

So, what I tried to do is using interrupt and run methods like
Thread.currentThread().interrupt()

That will stop the current thread from sleeping, or from waiting for some
I/O operation to complete. I do not see how it could help here.

Quote:
and Thread.currentThread().run(). This method showed the progress of
the computer play, but generates many exceptions. And, I think the cause
of the exceptions is that the program runs asynchronously.

It is not clear what thread you are calling this from, so I cannot really
tell what it is doing. But I cannot imagine any circumstances where that
would be a reasonable thing to do. Obviously, the current thread must be
running, so trying to "run" it is not a good thing. But also, the correct
way to start a thread is to call its start() method, not its run() method.
The run() method is the method that contains the code that a thread runs.

Quote:
What should I do?

Take a look at the javax.swing.Timer class.

--
Regards,

John McGrath

Back to top
Andrei Kouznetsov
Guest





PostPosted: Fri Nov 19, 2004 1:01 pm    Post subject: Re: Stopping for a sec to show a Graphical progress. Reply with quote



Quote:
Hi, I'm programming Risk, which is a board game, in Java as my homework.
My problem is that when computer plays the game, the program halts for 2
to 5 seconds and show only the final result. What I want to see is that
the program shows every single moves of computer play. So, what I tried
to do is using interrupt and run methods like
Thread.currentThread().interrupt() and Thread.currentThread().run().
This method showed the progress of the computer play, but generates many
exceptions. And, I think the cause of the exceptions is that the program
runs asynchronously. What should I do? Java GUI experts help me~!

place moves in some buffer (e.g. ArrayList) and use Timer to take next move
from buffer and make move.

--
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities



Back to top
Sangwoo Im
Guest





PostPosted: Fri Nov 19, 2004 9:23 pm    Post subject: Re: Stopping for a sec to show a Graphical progress. Reply with quote

Thanks for the help. I'm gonna try Timer class

"San" <woo0609 (AT) optonline (DOT) net> wrote

Quote:
Hi, I'm programming Risk, which is a board game, in Java as my homework.
My problem is that when computer plays the game, the program halts for 2
to 5 seconds and show only the final result. What I want to see is that
the program shows every single moves of computer play. So, what I tried
to do is using interrupt and run methods like
Thread.currentThread().interrupt() and Thread.currentThread().run().
This method showed the progress of the computer play, but generates many
exceptions. And, I think the cause of the exceptions is that the program
runs asynchronously. What should I do? Java GUI experts help me~!



Back to top
Sangwoo Im
Guest





PostPosted: Fri Nov 19, 2004 9:23 pm    Post subject: Re: Stopping for a sec to show a Graphical progress. Reply with quote

Thanks for the help. I'm gonna try Timer class

"San" <woo0609 (AT) optonline (DOT) net> wrote

Quote:
Hi, I'm programming Risk, which is a board game, in Java as my homework.
My problem is that when computer plays the game, the program halts for 2
to 5 seconds and show only the final result. What I want to see is that
the program shows every single moves of computer play. So, what I tried
to do is using interrupt and run methods like
Thread.currentThread().interrupt() and Thread.currentThread().run().
This method showed the progress of the computer play, but generates many
exceptions. And, I think the cause of the exceptions is that the program
runs asynchronously. What should I do? Java GUI experts help me~!




Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.