timer

show multiple MessageDialog at a time

只愿长相守 提交于 2019-12-20 02:47:10
问题 I am trying to make a program that displays 3 MessageDialog boxes at a time. I thought that if you put JOPtionPane.showMessageDialog in an actionListner class for a swing timer , it would show a new MessageDialog box every second. So here is the code that I came up with: package pracatice; import java.awt.event.*; import javax.swing.*; public class practice extends JFrame { public static int num = 0; public static TimerClass tc = new TimerClass(); public static Timer timer = new Timer(1000,

Extra argument 'selector' in call - NSTimer scheduledTimerWithTimeInterval

久未见 提交于 2019-12-20 02:37:09
问题 I have the following line of code: changeColour = NSTimer.scheduledTimerWithTimeInterval(TIMES, target: self, selector: "changeColourOfPage", repeats: true) but it gives the error "Extra argument 'selector' in call" when I change the TIMES variable to a number like 1.0 , it works fine. The variable TIMES is set to 1.0 . Is this just a glitch, or am I being stupid about something? I need to use it to run a method at random intervals. Please help! 回答1: It looks like you're missing the userInfo

Unable to start the timer in a service in android

萝らか妹 提交于 2019-12-20 02:15:48
问题 I dont know whats wrong going on... I am not able to start a timer in my service. Following the code public class BkgService extends Service{ private Timer ServUpdTimer = new Timer(); private static long TMR_INTERVAL = 10*60*1000; public void onCreate() { super.onCreate(); StartServUpdateTask(); } private void StartServUpdateTask() { if(ServUpdTimer != null) ServUpdTimer.cancel(); ServUpdTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { } }, 0, TMR_INTERVAL); } } But

Changing colors slowly, Java Graphics

99封情书 提交于 2019-12-19 22:06:08
问题 I have a gradient background and I want, slowly, for it to change colors, basically for it to go through different colors. The color has to blend through all the colors, I do not want it to flick through colors, is this possible? Please enlighten me with a solution, thanks. 回答1: Also consider java.awt.image.MemoryImageSource and a javax.swing.Timer , illustrated here and below. 回答2: Really too hard to say anything (whatever clever) to my defense, (try & enjoy) import java.awt.*; import java

How to repaint a jpanel every x seconds?

浪子不回头ぞ 提交于 2019-12-19 20:48:08
问题 i would like to know how to repaint and update the background of a JPanel every x seconds...This is my code: package view; import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; public class GamePanel extends JPanel { /** * */ private static final long serialVersionUID = 1L; private final JLabel

Start Thread with a given execution time

余生颓废 提交于 2019-12-19 20:37:43
问题 My main process calls an external library method. This method sometimes hangs. I can not fix the external library because another company is responsible for it. I want to use a Thread for the library calls with a defined execution timer. When the method call takes to long, the Thread with the Runnable in which the method call is placed should stop and the main process should go forward. Main Thread wait Execute Thread start Start timer Thread When timer thread is finished kill Execute Thread

Does VB6 Timer control create separate thread?

别等时光非礼了梦想. 提交于 2019-12-19 19:48:24
问题 Does the VB6 Timer control create a separate processing thread when it starts? 回答1: VB6 Timer controls are not some kind of busy-wait loop running on a background thread. They don't really "run" at all. As far as I can tell when you set Enabled = True (or change Interval if it was 0) the control makes a SetTimer() call. When you set Enabled = False (or set Interval to 0) it makes a KillTimer() call. The normal VB6 message loop (which of course runs on the UI thread) handles incoming WM_TIMER

.NET 3.5 C# Bug with System.Timer System.ObjectDisposedException: Cannot access a disposed object

偶尔善良 提交于 2019-12-19 17:52:27
问题 In my Windows service app I am using timers a lot. I'm using only System.Timers. I've never experienced this problem before, but suddenly I got this exception: System.ObjectDisposedException: Cannot access a disposed object. at System.Threading.TimerBase.ChangeTimer(UInt32 dueTime, UInt32 period) at System.Threading.Timer.Change(Int32 dueTime, Int32 period) at System.Timers.Timer.UpdateTimer() at System.Timers.Timer.set_Interval(Double value) at MyApp.MySpace.MySpace2.MyClassWithTimer

PowerShell timer/stopwatch accuracy

♀尐吖头ヾ 提交于 2019-12-19 17:43:23
问题 I find that the System.Diagnostics.Stopwatch class has what seems to be measurable inaccuracy, even over a short time period (i.e. 20 seconds). My process is showing an elapsed time of 20.3+ seconds for a process coded to run 20 seconds: $elapsed = [System.Diagnostics.Stopwatch]::StartNew() write-host "Started at $(get-date)" for ($t=1; $t -le 20; $t++) { Write-Host "Elapsed Time: $($elapsed.Elapsed.ToString())" sleep 1 } write-host "Ended at $(get-date)" write-host "Total Elapsed Time: $(

Swing Timer, how to pause and resume it?

情到浓时终转凉″ 提交于 2019-12-19 17:17:18
问题 i have a timer that counts the spent time and other calculations, but i need when i click on pause button the timer to pause, and then resume. How do i pause it? 回答1: There is no pause & resume API for Timer. You will need to code for it. Here is example which pauses and resumes Timer on mouseover. http://www.java2s.com/Code/Java/Swing-JFC/Anappletthatcountsdownfromaspecifiedtime.htm Hope this helps. 来源: https://stackoverflow.com/questions/3537484/swing-timer-how-to-pause-and-resume-it