Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-17-2007, 08:05 AM
Member
 
Join Date: Nov 2007
Posts: 6
Windoze is on a distinguished road
Pauses (or delays rather....)
Hey i was wondering if anyone knew how to make the code pause for a specified interval of time, at any place in the code that you place it.

thank you in advance.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-17-2007, 09:49 AM
Member
 
Join Date: Nov 2007
Posts: 8
lk9865 is on a distinguished road
Which IDE are you using?
if you are using Netbeans then what you can do is click on the line number once and you will see a red square pop up and then you can click on run->debug
it will run the program up until the red square and then you can click on play button to run the program line by line
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-17-2007, 11:44 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
You have two choices:
1 — use a Swing Timer with non-repeating delay, ie, one–time use. There's a page in the tutorial that discusses the use of Swing Timers: How to Use Swing Timers.
2 — use a thread:
Code:
Thread thread = new Thread(new Runnable() { public void run() { try { Thread.sleep(3000); } catch(InterruptedException e) { System.out.println("interrupt"); } } }).start();
This will halt everything: gui response, gui updates, etc; the app will appear to freeze.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delays by Play announcements koni123 Java Announcements 0 01-08-2008 11:51 AM


All times are GMT +3. The time now is 09:12 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org