timer

Animating Separate Objects

岁酱吖の 提交于 2019-12-14 04:06:46
问题 I've been working on an "elevator simulator" where I have to animate "elevators". I was able to create different elevator objects, which I did by having each Elevator Object have the parameters of width, height, and coordinates. I then stored them all into an array and used a for loop to draw them into my frame using JPanel's PaintComponent method. Can you guys suggest a way or give me advice to animate them separately from each other, like say move them up and down independently? I was able

Timer and TimerTask - how to reschedule Timer from within TimerTask run

倾然丶 夕夏残阳落幕 提交于 2019-12-14 03:53:42
问题 basically what I want to do is to make a Timer that runs a specific TimerTask after x seconds, but then the TimerTask can reschedule the Timer to do the task after y seconds. Example is below, it gives me an error "Exception in thread "Timer-0" java.lang.IllegalStateException: Task already scheduled or cancelled" on line where I try to schedule this task in TimerTask run. import java.util.Timer; import java.util.TimerTask; public class JavaReminder { public JavaReminder(int seconds) { Timer

Timer firing every second and updating GUI (C# Windows Forms)

不羁的心 提交于 2019-12-14 03:36:06
问题 I have a Windows Forms application where I need to have a timer working for 90 seconds and every second should be shown after it elapses, kind of like a stopwatch 1..2..3 etc, after 90 seconds is up, it should throw an exception that something is wrong. I have the following code, but the RunEvent never fires. private void ScanpXRF() { bool demo = false; System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); try { for (int timerCounter = 0; timerCounter < 90; timerCounter++) {

Bad timer in Windows service

做~自己de王妃 提交于 2019-12-14 03:35:08
问题 i have timer in my windows service, but the windows service does not do what it should do.. I want ask you, if i have good code with timer? Part of my code (updated): protected override void OnStart(string[] args) { timer = new System.Timers.Timer(); timer.Elapsed += new ElapsedEventHandler(getFileList); timer.Interval = 10000; timer.Enabled = true; timer.AutoReset = false; } private void getFileList(object sender, EventArgs e) { //Work with xml... DeleteOldBackupFiles(); } private void

Using timers to query DB table rows with different flag column values

孤者浪人 提交于 2019-12-14 03:34:47
问题 I want to identify specific mysql db column value using timer. For example, I have 6 timers and in database I have a column named flag , and its values are 100, 100, 100, 103, 103, 106, 107, 107, 107, 108, 108, 109 . I want: 1st timer to work with three 100 values, 2nd timer to work with two 103, 3rd timer to work with one 106 value, 4th timer to work with three 107 values, 5th timer to work with two 108 values and 6th timer to work with one 109 values. How do I assign these values ( 100, 103

Thread.sleep vs Timers

给你一囗甜甜゛ 提交于 2019-12-14 03:33:17
问题 So in my research I have found these main differences between using a timer to execute an instruction and executing an instruction then making the thread sleep. Observe the following code public class StkFlow { public void event(ActionEvent e){ //do some stuff } public static void main (String [] args){ Timer tick=new Timer (200, event); tick.start (); } } AND public class StkFlow { public static void main (String[] args){ while (/*Condition*/){ //Do some stuff Thread.sleep (200); } } The

document.write is killing page

早过忘川 提交于 2019-12-14 03:32:17
问题 I created a timer and did not notice the document.write was killing the page because everything was working great. However, when the timer goes to 0, it only displays what is in the document.write function rather than everything else in my page. This is what is killing the page and only the text in ()'s is what is showing.. document.write("The NFL Season is here!!"); How can I make this so that the timer would stop and this text displays or this text can display on my page without killing the

Stop watch delay using timer c#

混江龙づ霸主 提交于 2019-12-14 03:25:32
问题 I want to add a stopWatch to my form but the one i made is lagging behind the time of other timer in pc. Can you give any solution for that? (My timer interval is 100). this is my code: int min, sec, ms = 0; private void timer1_Tick(object sender, EventArgs e) { Time.Text = min + ":" + sec + ":" + ms.ToString(); ms++; if (ms > 9) { ms = 0; sec++; } if (sec > 59) { sec = 0; min++; } } private void timer_Click(object sender, EventArgs e) { timer1.Start(); } It working but with easy delay. I

Getting an input from the user without having to wait - C language..!

半世苍凉 提交于 2019-12-14 03:25:28
问题 I'm currently programming a simple timer, which runs from 00s to 55s and then start from 00 again and keeps counting until the user stops it. For that purpose I made two options for the user: 1. start & 2. reset. Choosing number one runs the program, and choosing number two, as I its supposed, will turn the timer in to 00s and keep it there. Now the problem I'm facing is that I want to get an input from the user without stopping the timer (i.e. enabling the user to enter 2 at anytime while

How to Stop Javax.Swing.timer?

[亡魂溺海] 提交于 2019-12-14 02:53:35
问题 I'm a java newbie and I'm creating a scheduler program using netbeans. My software will get Time and action from the user and enter those data in to separate arraylists. I've then used javax.swing.timer to start a countdown timer. When user finished entering data and hit the "run" button,The timer will get the running time from the first element in the array list and start counting down. when the countdown time reach 0 , timer will get the count down time from the next element in the array