Advertisement

02.26.2006 at 07:50PM PST, ID: 21752553
[x]
Attachment Details

How do I make JAVA sleep or pause while still reacting to events?????

Asked by Davehudsn in Java Programming Language

Tags: java, sleep

I have a JAVA program with JButtons on a panel.

Long story short, the program does quick calculation and then moves a graphic object.  If I let the program run full speed, it makes all its moves in a few seconds and the end user can't see all the moves.

So I want to put a pause or sleep in the "loop" so it waits about 1 second between turns.

The problem I have, is that I want the end user to be able to click on other JButtons to modify the program as it runs. Since the program is running as a single thread, when i do a sleep or pause, it freezes up the whole program interface.

In Visual Basic, there is a sleep command that pauses the current thread, but the GUI still reacts to events that are triggered.

How do you do that in JAVA???
Start Free Trial
 
 
[+][-]02.26.2006 at 08:07PM PST, ID: 16052618

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.26.2006 at 08:29PM PST, ID: 16052685

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.26.2006 at 11:35PM PST, ID: 16053328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.27.2006 at 12:28AM PST, ID: 16053550

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.27.2006 at 05:20AM PST, ID: 16054768

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.27.2006 at 05:32AM PST, ID: 16054847

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2006 at 05:43AM PST, ID: 16054931

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: java, sleep
Sign Up Now!
Solution Provided By: mayankeagle
Participating Experts: 5
Solution Grade: A
 
 
[+][-]02.27.2006 at 12:57PM PST, ID: 16058946

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.27.2006 at 06:58PM PST, ID: 16061696

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2006 at 06:59PM PST, ID: 16061699

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2006 at 07:01PM PST, ID: 16061707

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32