How to stop swing timer

Hello,
I use Swing timer in my application but it seems that timer.stop() does not work. I put System.out.println("hello") in the method that is the timer's actionlistener and even after I call timer.stop(), it keeps printing "hello". Is there any thing other than timer.stop() that I should do to stop the timer?
Thanks a lot

ladybean wrote:
Thanks a lot for your reply. Well I only have one timer in the code. Another funny thing that is happening is that the timer gets faster over time. As you and I both know, this shouldn't be happening. I believe that you have one Timer variable, but are you sure that you don't have more than one Timer object? Again, this is just a SWAG, but this would also explain the increased speed over time.
I set the delay time of 1 second but I see that my animation moves faster over time. The reason that I don't upload code is that it's really long and complicated. Maybe I should make it simpler and upload it. This is a very very good idea. We have a construct that's often used here called a SSCCE or "Short, Self Contained, Correct (Compilable), Example" that helps guide folks in creating a small compilable and runnable version of their problem, and often helps them to see their error for themselves (there's a lot to be said for simplifying the problem to examine it). Please have a look at this link for more details: [http://sscce.org/]
Thanks again though. :)You're welcome. Oh, and if you do resolve this on your own, please post back to let us know what happened and why. Best of luck!

Similar Messages

  • How to Stop the timer in the TimedTrigger UI element when an event occurs

    Hi all
    I have a webdynpro View where i have many UI elements(which supports an event)  along with TimedTrigger UI element.
    Now my requirement , i want to check at single line if any event happens in the View then i want to stop the timer in the TimedTrigger UI element.
    can you please provide any peace of code related to this??
    Thanks
    Bindu

    Hi Bindu,
    From help.sap.com:
    http://help.sap.com/saphelp_nw70/helpdata/EN/03/7c6b40dde0980ae10000000a155106/frameset.htm
    To prevent events being triggered by UI element TimedTrigger, proceed as follows:
    1. Disable the action that is bound to the UI elementu2019s onAction property.
    Can be done as:
    wdThis.wdGet<Your_TimedTrigger_action>Action().setEnabled(false);
    2. Set the value of the delay to 0 seconds
    As suggested in previous post to this thread.
    3. Disable UI element TimedTrigger
    Create a boolean type of context attribute and bind it to the "enabled" property of the Timed Trigger. Set its value to false to disable the timed trigger.
    Regards,
    Alka.

  • Video Streaming - How to stop buffering time?

    Hi
    I am trying to watch a tv show I missed on NBC,
    "age of love" but the replay stops every minute
    to download more video I think. How do I improve
    the performance so I can watch the show without
    the constant interruption?
    thanks in advance
    Mark S
    iBook G4   Mac OS X (10.4.8)   756 RAM

    I don't know the speed of the connection.
    4-10 users usually.
    .11b or .11g I don't know.
    microwave nearby - I don't know
    5-6 other wifis - yes
    I will try Safari, thanks!
    Thanks for the update. The speed of the Wi-Fi in the
    coffee shop will depend on many factors. What is the
    speed of their connection to the Internet? How many
    people are sharing the Wi-Fi? Is it 802.11b or
    802.11g? Do they have a microwave operating nearby?
    That will often interfere. Are there additional Wi-Fi
    networks nearby? That can interfere as well. It's
    possible that it was their network that's causing
    your trouble. But, to rule that out, did you try
    using Safari instead? You might make sure you have an
    up-to-date version of the Flash player which you can
    get at http://www.adobe.com
    I have Clearwire
    at home, it's basically like wireless DSL. It's not
    as fast as cable Internet access, but it is portable.
    I only mentioned it because it would indicate that
    you don't need cable speed to watch the videos
    without buffering.
    -Doug

  • How to stop my Time Machine external hard drive preventing iMac from sleeping?

    I have a late 2012 iMac, and have discovered that sometimes (I haven't noticed a pattern of when it doesn/doesn't happen) the computer will immediately wake up after I set it to Sleep (Apple Menu>Sleep). Through elimination I have found that it is the the USB 3.0 external hard drive I use as a Time Machine back-up that is the culprit; unplugging it then allows the computer to sleep. If I unplug it, then plug it back in later on, this normally solves the problem for a while, but not forever. This same Hard Drive didn't cause the wake problem on my previous '08 iMac.
    A big issue is that when the machine immediately wakes from sleep, the display stays off (until I move the mouse) - this is good from a power saving point of view, but means I don't know if/when the machine is immediately waking from sleep (I have to listen to the fan when setting it to Sleep mode to hear if it has actually woken back up).
    I've searched the forums, but can't find another poster with the same problem as myself. Can anyone advise a course for me to pursue to prevent this from happening?
    Thanks. Jamie

    Hi Frank. Nope, I'm still having the same symptoms; the plugged in external drive (TIme Machine) will wake the machine up a couple of seconds after it winding down when put to into sleep mode. Ejecting the drive and then sleeping the machine works. After plugging it in again to do a Time machine backup, it will allow the computer to sleep soundly for the first few sessions (eg a few days of sleeping, waking, sleeping, waking, etc), but then it will then suddenly start preventing it from sleeping again after a while.
    It seems I'm fortunate in my case that the display stays dark (or off?) when the machine has been woken from sleep, but this was actually preventing me from knowing the machine wasn't in fact asleep for quite some time; I only eventually cottoned on because there wasn't any delay when 'waking' my machine (which there normally is). I would then have to carefully listen to the spinning fans to know if in fact it had gone to sleep or not.
    So, to summarise, unfortunately no, I haven't solved this yet. If anyone else has a solution, please let us know?
    Also, I've noticed occasionally after waking that there is a relatively quiet 'crackle' sound (kind of electrical sounding) from the bottom-right area of the machine. This goes on every so often for about 30mins. I see this is also an issue with other people's late 2012 iMacs, but I've not seen if anyone has a solution to it?

  • How to stop Timer event inside movie clip that does not exist?

    Hello. I am using Adobe Flash CS6.
    As this topic title says. how to stop Timer event nside movieclip that does not exist?
    I mean my fla stracture is  there are 2 frames on main timeline, and I put mcA on frame 2.
    And I put a button on root that does
    if(currentFrame ==1)
    gotoAndStop(2);
    else if (currentFrame ==2)
    gotoAndStop(1);
    And mcA has AS inside and it is
    var T_Timer:Timer = new Timer(1000,0)
    T_Timer.addEventListener(TimerEvent.TIMER, test)
    function test(e:TimerEvent):void{
    trace("Timer active")
    T_Timer.start();
    I need to stop T_TImer from root on frame 1, not on frame 2.
    but, "mcA.T_Timer.stop();" won't work.
    I get TypeError: Error #1010 error.
    I don't know how to stop this timer event. I have to stop it from root, and I can't use EVENT_REMOVED in this case.

    If the object doesn't exist you cannot do anything relative to targeting it.  Maybe you should move the timer to the main timeline where you can access it any time.

  • How do I stop and start a Swing Timer?

    I have created a Swing timer;
            new Timer(250, Task).start();but can't figure out how to use the .stop() and .restart() methods?
    How do I code this?
    TIA

    I found the answer;
      SimKitsControlTimer = new Timer(250, SimKitsControlTask);
      SimKitsControlTimer.start();Not as prevously written.
    I was trying to create an object with the .start() method at the end of the line. Doh!

  • How can I wait until a Swing.Timer has finished?

    I have a Swing.Timer runing which displays some animated text (more precisely it fades out a text with a delay of 50 until all characters are erased.
    Afterwards a time consuming operation shall begin. How can I achieve that this operation waits to start until the text has been faded out? The time to fade out the text depends on the length of the text, of course.
    So, how can I make the operation waiting until the Timer has finished its work?
    Thanks,
    Dirk

    dirku wrote:
    I have a Swing.Timer runing which displays some animated text (more precisely it fades out a text with a delay of 50 until all characters are erased.
    Afterwards a time consuming operation shall begin. How can I achieve that this operation waits to start until the text has been faded out? The time to fade out the text depends on the length of the text, of course.
    So, how can I make the operation waiting until the Timer has finished its work?I gave you an answer to this with sample code yesterday:
    [http://forum.java.sun.com/thread.jspa?threadID=5294087&messageID=10244564#10244564|http://forum.java.sun.com/thread.jspa?threadID=5294087&messageID=10244564#10244564]
            public void actionPerformed(ActionEvent e)
                if (sb.length() > 0)
                    sb.deleteCharAt(0);
                    label.setText(sb.toString());
                else
                    label.setForeground(color);
                    label.setText(text);
                    Timer timer = (Timer)e.getSource();
                    timer.stop();
                    // ***** start process here ***
            }The timer here continues until a condition is satisfied (here it's where the Stringbuffer that holds the text that is sent to the JLabel is empty). So all you have to do is place any code that needs to happen when the Timer ends in the else block. It's so simple as to be trivial.

  • How to kill all swing.Timer(s) at end of App

    I am using a javax.swing.Timer to cause text to flash in the text field. However, I noticed that if this timer is running when I stop my app, the timer's thread is still running. It appears that the class that has the timer is not being garbage collected immediately upon application exit. Is there a way to kill all swing timers?
    Thanks,
    John

    No. This is a class whose implementation I was hoping the main application would not have to know about. I was hoping that since I was using swing timers that when the application on which thread the swing timers are executing exited, all the swing timers attached to that application would be stopped.
    Do you have a suggestion how I might be able to do this? I have an application "A" that uses a library class "B" method that happens to start a timer. I do not want "A" to have to explicitly stop "B" when the application is ending. Is there a way I can tag the timer so that it will stop when "A" exits? Or could I somehow link "B" to "A" so that a dispose method on "B" is called when "A" exits or disposes?
    Thanks,
    John

  • How to stop multiple auto-switching to address bar every time I open a new tab and try to type something anywhere outside of address bar?

    How to stop multiple auto-switching to address bar every time I open a new tab and try to type something anywhere outside of address bar? Like something just wants me to use that embedded search when u type something not-web-address in address bar and hit enter. And the most ridiculous thing is that it happens repeatedly on like every second, like I just move down from address bar and start typing again, but then again it switches me to address bar, and 3, 4 times like that. And the result is also that I can't see the address of that page.
    I think its has something to do with my AVG antivirus, because this started the same time some AVG Nation started to appear in every new tab i open (and thats also irritating me, I read about it here on support.mozilla.org and it seems that the only solution is to completely reinstall Firefox, but I dont want to lose all my settings) but when i type something in address bar and hit enter it opens the search results in Google.
    Please try to help me, I like Firefox but I must switch to Chrome until I fix this problem.
    Thanks in advance

    First, please update to Firefox 32. 22 is no longer support nor is it secure. Then let us know if you still have this problem. [[Update Firefox to the latest version]]

  • My Mail app opens unprompted everytime i reboot or awake my macbook pro from sleep.  This was not an issue until i shut down my laptop for the first time in a while 2 days ago.  ANy ideas how to stop this?

    I recently shut down my MacBook Pro for the first time in a long time.  SInce then, everytime i reboot or awake my laptop from sleep, the Mail app opens unprompted causing my computer to slow down incredibly, and some apps to freeze.  I have no idea how to stop this or why it even started doing this.  Any ideas on how to get it to stop? Thanks!

    I have this problem too with my Macbook Air. Mail opens automatically every time my laptop sleeps. I actually just asked about this in my own thread. However, it is not causing my apps to freeze.

  • How to stop Time Machine from backing up Temp Files?

    Hi folks!
    I am trying to find out how to stop Time Machine from constantly backing up 'useless' temporary files accumulated from web browsing? Although I don't change or add large files to my HD, Time Machine backs up hundreds of MBs every hour. Those file amounts make sense when I consider that I browse a lot to YouTube, SoundCloud, etc to watch videos or listen to music - I just don't want them to be backed up.
    Under Time Machine Options I already excluded the following items from backups:
    ~/Library/Caches
    /Library/Caches
    ~/Downloads
    But even though I did this weeks ago, Time Machine stills finds large files to be backed up every hour and my only guess is that I am still missing a location where either Safari or Firefox - the two web browsers I use - store temporary files.
    Can you help?
    Thanks a lot in advance!

    oas2103 wrote:
    they come from my anti-virus software
    Are you sure you need that? There are no viruses that run on OSX. None. Zip. Zero.
    If you're running Windoze on your Mac, that's the same as running it on a PC, so it needs all the same anti-everything stuff you'd use on a PC.
    There is some "malware," such as Trojans, for Macs, though. But (unlike viruses that can get onto your system without your knowledge), you must approve their installation (via your Admin password) and/or operation (via the "This application was downloaded from the internet ..." prompt).
    Appropriately enough, some of these Trojans are included in pirated versions of Apple software, such as iWork!
    For the gory details, see Thomas Reed's [Mac Virus Guide|http://www.reedcorner.net/thomas/guides/macvirus].
    Thanks a lot again!
    You're quite welcome, and thanks for posting back.

  • HOW TO STOP THE PROMPTING MESSAGE OF MASTER PASSWORD EACH TIME I OPEN MOZILLA FIREFOX?

    HOW TO STOP THE PROMPTING MESSAGE OF MASTER PASSWORD EACH TIME I OPEN MOZILLA FIREFOX?

    Firefox will ask for the Master Password on startup if it is needed on a page.<br />
    This can be Sync or a web page that is (re)opened automatically and you have saved a name & password for this website.
    You didn't confirm whether you are using Sync or not, so I don't know which of the two would apply.

  • How to stop the new Photos.app opening every time I put in a new device?

    How to stop the new Photos.app opening every time I put in a new device?
    It's annoying as i use bridge to do all my photo organising.

    Insert or attach a device then let Photos load. Then uncheck the box indicated:

  • I have been sampling new imported drum loops. And if I adjust region to song or time strecth it updates the audio file in the library. How to stop this? I lost the original setting to one loop. automatically doing it ??

    I have been sampling new imported drum loops. And if I adjust region to song or time strecth it updates the audio file in the library. How to stop this? I lost the original setting to one loop. automatically doing it ??

    This "original file cannot be found" thing happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, or that the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout,or vice-versa, and so is looking in slightly the wrong place.
    Select a track with an exclamation mark, use Ctrl-I to get info, then cancel when asked to try to locate the track. Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, or a drive letter has changed, it should be possible to reverse the actions.
    Alternatively, as long as you can find a location holding the missing files, then you should be able to use my FindTracks script to reconnect them to iTunes .
    tt2

  • How to stop process chain, if it is taking too much time than expected.

    Some times if a process chain takes to much time to finish than expected, how I can stop the process chain and execute it again.
    Thanks in Advance.
    Harman

    how I can stop the process chain ??
    If the job is running for a long time ,
    1)GOTO RSMO and SM37 and check the long running job over there.
    2)There you can see the status of the job.
    3)If the job is still running you can kill that job
    4)delete the failed request from data target.
    for more details go to this below link
    how to stop process chain if it yellow for long time
    how I can execute it again ?
    GOto Function module  RSPC_API_CHAIN_START
    and give u r process chain name there.and execute.

Maybe you are looking for