473,395 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

a timer in a for loop

hey

i need help. ive been trying to put a timer in a for loop, but it doesnt seem to work. need help. thanx.

i want the data printed in every array to be delayed by a few seconds

heres the code
Expand|Select|Wrap|Line Numbers
  1. class ButtonListener implements ActionListener
  2.       {
  3.         private static final int TIMER_DELAY = 2000;
  4.         protected static final int COUNT_MAX = 160;
  5.         protected static final int DELTA = 1;
  6.  
  7.         public void actionPerformed(ActionEvent arg0)
  8.         {
  9.  
  10.                  InsertionSort(numbers);
  11.                    new javax.swing.Timer(TIMER_DELAY, new ActionListener()
  12.                   {
  13.                     public void actionPerformed(ActionEvent arg0)
  14.                     { 
  15.                  for(int i=0;i<5;i++)
  16.                  {
  17.  
  18.                    for(int j=0;j<5;j++)
  19.                    {
  20.                      System.out.print(sortedArray[i][j]+ "\t");
  21.                    }
  22.                    //move to new line
  23.                    System.out.print("\n");
  24.  
  25.                  }
  26.                        }
  27.                    }
  28.                    ).start();
  29.         }
  30.       }
Nov 26 '08 #1
1 1884
JosAH
11,448 Expert 8TB
Have a look at the Thread.sleep() method; it makes the current thread sleep for a number of milliseconds.

kind regards,

Jos
Nov 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: RitaG | last post by:
Hi. I Have a VB.Net Windows Application that starts up using Sub Main. It's a program that runs in the background and checks something every minute. I use a Timer to accomplish this and it's...
8
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
11
by: avivgur | last post by:
Hello, I have devised a console application that uses a System.Timers.Timer and its Elapsed event. The problem is that I want the program to continue to run so that each time the event is raised,...
3
by: Kenny | last post by:
I am running a windows service that takes actions based on a couple System.Threading.Timers. The intervals are usually short... based on the time of day, anywhere between 1 and 5 minutes. ...
4
by: hazz | last post by:
given namespace WindowsService1 { public class Service1 : System.ServiceProcess.ServiceBase......... private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { ArrayList...
14
by: Crirus | last post by:
This is more a logical problem than a VB. I have this situation: A timer that need to tick at each 10 minutes starting on minute 15 of curent hour. But I want to calculate the next tick...
6
by: Aart Nicolai | last post by:
Hi all, I have developed a vb.net console application which will run some code every seconds. To get this working I used a timer "System.Timers". When I start my console application it exits...
4
by: Lemune | last post by:
Hello everyone. I'm using vb 2005. I'm creating program that run as service on windows. And in my program I need to use timer, so I'm using timer object from component. I try my source code on...
4
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
2
by: John O'Flaherty | last post by:
Hello, I'm having trouble with the timer control in VB6. I have a form with a timer control and a command button, and this simple code: Dim TimeOut As Boolean Private Sub Form_Load()...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.