Only want one counter/timer,  keep getting far more.

My problem is that if a apply a new number to the counter/timer while it's still running, it adds a new counter along with the previous counter.
Is there a way of reseting the first counter to use the new chosen numbers.
I can cancel the old with a second button within the main timer method.
But I would like to cancel or reset from the select button.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.math.*;
import javax.swing.Timer.*;
public class CountDown3 extends JPanel
  JList list;
  DefaultListModel model;
  int counter = 1000;
  String time;
  final int SECONDS = 60;
  int minutes = 0;
  JButton btn2 = new JButton("end");
  public static void main(String s[])
      JFrame frame = new JFrame("List Model Example");
      frame.setContentPane(new CountDown3());
      frame.setSize(70, 80);
      frame.setVisible(true);
  public CountDown3()
    setLayout(new BorderLayout()); model = new DefaultListModel();
    list = new JList(model);JScrollPane pane = new JScrollPane(list);
    pane.setPreferredSize(new Dimension(100,22));
    JButton btn = new JButton("Min");
    for (int i = 1; i < 1000; i++)model.addElement(""+i);
    list.setSelectedIndex(0);add(pane, BorderLayout.NORTH);
    add(btn,BorderLayout.WEST);add(btn2,BorderLayout.EAST);
    btn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent ae)
               int bob = list.getSelectedIndex();
               if(bob == JOptionPane.OK_OPTION);
                    String time = (String)list.getSelectedValue();
                   System.out.println(time);
                   ddd(time);
  public void ddd(String time)
     final java.util.Timer sid = new java.util.Timer(true);
     minutes = Integer.parseInt(time);
     sid.scheduleAtFixedRate(new TimerTask()
        int bbb = minutes * SECONDS;
        public void run()
               System.out.println(""+bbb/SECONDS+" : "+bbb % SECONDS);
                  bbb--;
             if(bbb < 0)
                       sid.cancel();
    },0,1000);
}

A little modification try this
Your program is good and superb
/* Try JSpinner instead of using JList with JScrollPane ... */
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.math.*;
import javax.swing.Timer.*;
public class CountDown3 extends JPanel{
  JList list;
  DefaultListModel model;
  int counter = 1000;
  String time;
  final int SECONDS = 60;
  int minutes = 0;
  JButton btn2 = new JButton("end");
  java.util.Timer sid=new java.util.Timer();
  public CountDown3(){
    setLayout(new BorderLayout());
    model = new DefaultListModel();
    list = new JList(model);
    JScrollPane pane = new JScrollPane(list);
    pane.setPreferredSize(new Dimension(100,22));
    JButton btn = new JButton("Min");
    for (int i = 1; i < 1000; i++)
        { model.addElement(""+i); }
    list.setSelectedIndex(0);
    add(pane, BorderLayout.NORTH);
    add(btn,BorderLayout.WEST);
    add(btn2,BorderLayout.EAST);
    btn.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae)
               int bob = list.getSelectedIndex();
               if(bob == JOptionPane.OK_OPTION);
                   String time = (String)list.getSelectedValue();
                   System.out.println(time);
                   sid.cancel();
                   ddd(time);
  public void ddd(String time){
        sid= new java.util.Timer(true);
     minutes = Integer.parseInt(time);
     sid.scheduleAtFixedRate(new TimerTask(){
        int bbb = minutes * SECONDS;
        public void run(){
               System.out.println(""+bbb/SECONDS+" : "+bbb % SECONDS);
                  bbb--;
             if(bbb < 0)
                       sid.cancel();
    },0,1000);
  public static void main(String s[]){
      JFrame frame = new JFrame("List Model Example");
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      frame.setContentPane(new CountDown3());
      frame.setSize(70, 80);
      frame.setVisible(true);
}

Similar Messages

  • Well my sis bought a whole album and I only wanted one song cAn I get my money back

    I need to get this answered

    All sales are final.  You can try and plead your case to the store support staff and see what they will do for you, http://www.apple.com/emea/support/itunes/contact.html

  • Tried to upgrade and after uninstalling and reinstalling several times, keep getting "procedure entry point could not be located in dynamic link library" followed by "iTunes was not installed properly"  Error 7.....Help, please??

    Tried to upgrade as instructed and after uninstalling and reinstalling (even back to the former iTunes which I was happy with)several times, keep getting message "Procedure entry point could not be located in dynamic link library"  followed by "iTunes was not installed properly"  "Error 7".    Help, please??

    Entry point errors can usually be fixed by deleting the offending dll, then repairing the component it is part of from the programs and features control panel. Unfortunately you neglected to include the detail of which dll is mentioned.
    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • Hello, I'm having trouble getting to the page where I can put in my activation code for my One to One. I keep getting ID or Password error. Have already reset twice- HELP Plz.

    Hello, I'm having trouble getting to the page where I can put in my activation code for my One to One. I keep getting ID or Password error. Have already reset twice… HELP Plz.

    sashaburg wrote:
    Unfortunately Netgear's support isn't very supportive.
    Without Airport set-up, and without wireless connection, I can't talk between macs either.
    Ok, this is a mac question: With the order changed so that the ethernet comes first, why is it still showing my connection to the neighbor's wireless? Am I reading that wrong? OR am I connected to both at the same time? If so, why would it connect twice to the internet?
    Probably because you neighbor has no security on his network. Does his network show a lock like
    If it does he's got security turned on, if there is no lock showing he hasn't turned it on.

  • I created a watermark in LR4 and it applied to all photos I only wanted one photo marked.

    I created a watermark in LR4 and it applied to all photos I only wanted one photo marked. How can I keep it from adding the watermark to all of my photos?
    I want to be able to add them manually to each photo in a location that I chose so the photo is still visably appealing.
    Thanks!

    I think it's a feature of the Web Module, since it is assumed that you would want the watermark on all images of a web-gallery.
    But, in this context (as always is the case in Lr) you have to take into consideration of how Lr works. Lr never ever changes your originals.
    "Watermark applied" means only that there is a set of data in the Lr catalog that says something like "when uploading the web-gallery the watermark has to be applied to the uploaded JPGs".
    Nothing has been done to your originals - even though they are displayed in te Web Module with the watermark. The orginals are ever unchanged.
    If you go back to the Library Module (within the same Collection) you won't see a watermark.

  • Only want one image version in MobileMe album

    When I add a version to a MobileMe album, all of the versions are added to the album. When I delete the other versions from the MobileMe album, those versions are deleted from my library.
    I only want one version added to the MobileMe album... and the other versions to remain in my album.
    Any ideas?
    Thanks!

    Within Aperture you have Images, which are constructed on-the-fly from two files (the Master and the Version).  You get an image-format file _only_ when you export an Image.  You select the file name (usually a scheme) when you create an image-format file (that is, when you export).  Look under "Aperture→Presets→File Naming" for built-in Presets.  You can, of course, create your own or customize any provided.
    The Preset is applied to only the file newly created by your "export" command.  It is not applied to the Image in Aperture (unless you rename your Versions or your Masters).

  • I only want one app for now

    I currrently have Adobe Creative Cloud and only want one app for now which is Photoshop .... I accidentally installed Lightroom, Bridge CC, Exchange Panel, Extendscript toolkit, Extension manager, touch app plugins from Creative Cloud and would like to uninstall these apps until I have a full understanding of the Creative Cloud. 
    I pay monthly for membership and do not want to uninstall the Creative Cloud.
    Please advise on how to uninstall these other apps.
    Thanks.

    Hi Margaret,
    Please use the cleaner tool to remove the app that you would like to uninstall:
    http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html
    Choose the best option as per your decision.
    Regards,
    Rajshree

  • TS3276 Does anyone have problems with sent messages not showing in their Mail? I have two sent folders when really I only want one. Any tips?

    Does anyone have problems with sent messages not showing in their Mail? I have two sent folders when really I only want one. Any tips?

    Not sure if this is a fix, but I tried sending myself a test email from only  the Bcc field, and lo and behold it now shows the Bcc field in all sent item previews;
    ...maybe leaving the 'To' field blank on purpose forced Mail to show it.
    Rebooted the Mail program, still there - rebooted the machine, still there. Hope this is still relevant and it works for you too - J.

  • I accidentally pressed download to the whole album but I only wanted one song??? Help please ??

    I was on iTunes on my iPhone and I accidentally pressed the download for the whole album! But I only want ONE song!! Of course it's one of those DJ songs where all 10 songs the same. ( who wants all of those) . Now my whole iTunes card is gone too! Please is there a way to fix this!! Ill never buy music on my phone again!

    Actually most of the album is paused in my download box if that helps??

  • I am trying to restore my old Macbook Pro data using Time Machine on a new Mackbook Air from external hard drive, but when I install I get two different loggin accounts and I only want one loggin account

    I am trying to restore my old Macbook Pro data using Time Machine to a new Macbook Air from an external hard drive, but when I restore I get two diferrent loggin accounts and I only wnat one loggin account to access all my data/files?

    This web site might answer all of your Time machine questions:
    http://pondini.org/OSX/Home.html
    Ciao.

  • I recently purchased an iMac and used migration assistant to get all files from my emac, but now I have three user accounts.  I only want one (perhaps two) accounts.  I want all my music, photos and word docs from old computer in one user name

    I recently purchased a mac and used a firewire to transfer my files onto my new imac with migration assistant.  Now I have 3 users.  I want one with all my main files (pictures, music, files from my old computer).
    I don't mind having an additional "family" account so my younger daughter can't mess us things, but I can't figure out how to get files from one to the next and then delete the one user name.
    Thanks,

    In order to delete other accounts you must be logged into an admin account. You cannot delete the account into which you are currently logged.
    When you started the new computer you were in the Setup Assistant. You created a new admin account before finishing the setup. You need to log into that account because it is an admin account. You can then delete the account you migrated from the old computer (and any other accounts you don't need or want.)
    Then create a temporary new user account with admin status - name it, Temp. Log out of the current account and log into the new account, Temp. Now delete the initial account you created in Setup Assistant. You now have one account, Temp. Now re-migrate your data from the old computer. When that is completed log into the migrated account, which should be an admin account, and delete the temporary account, Temp.

  • I have two iCloud accounts .mac and .me. My contacts are duplicated 2 and 3 times. I only want one account.

    Somehow, I ended up with two iCloud accounts. A .mac and a .me. I only need one but can not make the .me the primeray one (it tells me that the email is already in use). Anyways, I also have my contact records duplicated 2 and 3 times. I went to the Apple store in Beijing (I'm in China now) and they did not seem to know much about iCloud. They told me that I have to erase my contacts on the iPhone and iPad and then manually erase the duplicates. Is there another way to do it? How can I set up iCloud so that I only have one account?

    You can't delete an iCloud account.  You can, however, sign out of that account and just stop using it.  Then sign in to your second account on all devices account. 
    OT

  • Regular tv shows and HD both load and I only want one!

    Seems like sometimes when I download a tv show I will get the regular version and the HD version. I only want the regular version since it's cheaper so I delete the HD version but they are still in my Available Downloads list and every time I try to delete them, they come back! And every time I buy something new...they show up and start downloading again. How can I delete these HD duplicates of shows I already have once and for all??

    Im not sure how to delete them, but there is a simple solution to not getting them at all:
    When you download an HD version of something (TV show, Movie) you get BOTH the HD version, and then you get the STANDARD version free. Sort of like a bonus to put it on your iPod (if you have one) since they won't play HD versions.
    Now, if they are still appearing in your queue to download, I would just let them download then delete the files. Either way, you paid for them.
    On that note, though, you can send the iTunes folk an email saying that you downloaded the HD by mistake and they may credit your account back. That can be done by going into your account and using the "Report Problem" service.
    blakewt

  • My (Snowleopard) MBP died, but I had it backed up externally with TimeMachine. I bought an Air and used Migration Assistant which worked to bring the data over.  However, I've now got two versions of "me" on Air - I only want one with all my info. Help!

    I know it's generally recommended (if you're going to bring data from one machine to another) to update the OS on the source computer before transfer.  However, my MBP died unexpectedly and my information was backed up with TimeMachine in SnowLeopard.  The Air I bought as a replacement runs Lion.
    I was able to use Migation Assistant to bring my info/programs/etc over...but I've now got the user set up initially (in store) with Lion when I made the purchase - and I now have a second "persona" that contains all of my backed up information from the time capsule.
    Given that the Airs have (relatively speaking) smaller amounts of memory, and that I dont' want to be bouncing back and fourth between profiles, I'm wondering if it's safe to delete the "new user profile" (ie the one set up via Lion while in store) and just use and keep the "me" I brought in from the time capsule.
    I've never updated a MacOS before - let alone under these circumstances, so I've got a fair amount of trepidation around the whole process.
    What is the best way to wind up with one user profile, keeping all the information from my old machine and deleting anything superfluous as part of a secondary profile?
    Thanks in advance for any input you can provide surrounding this process! 

    Thank you! 
    I can't tell you how terrified I was when deleting the superfluous account...but it went just swimmingly!

  • Why do albums in iTunes Match only partially download? I keep getting unable to download messages....These are albums I have purchased previously.

    I have been trying to download some of my favorite albums from my collection on to my phone, and on many of my albums, only part of the album I successfully downloaded.  I keep getting a message saying tho song is unable to download retry or done?!? This is over wifi and I have had this previously downloaded on my phone---before changing to iTunes Match!

    Hi,
    You cannot manually manage music with match turned on on your iOS device. If you want to manage music manually, you will need to turn off match on your iPhone.
    Jim

Maybe you are looking for

  • Unable to get the connections due to access denied error.

              Hi All,           I am trying to use my adapter in WebLogic Server 7.0 and get the following exception           while requesting for a connection by doing getConnection. The ex is as follows -           <May 23, 2002 11:08:22 AM PDT> <Erro

  • Error in import in phase TOOLIMPD3

    Hi all, I am posting with a problem I have just encountered upgrading my Dev 46C system to ECC. I didn't encounter this upgrading my sandbox. During the prepare phases, I encounter an error in the phase TOOLIMPD3: ERROR: tp terminated with error stat

  • Crashes on Chrome

    This latest version of flash player keeps crashing on Google Chrome Version 27.0.1453.94 especially when I am on facebook.  Is there a solution for it? Please I need urgent answer this is frustrating. Daily Healthy Tips >>>   www.dhealthytips.com

  • HT201250 what to do when external drive is full

    My IMac is almost full. It has 240 out of 250Gb being used. My external hard drive has two partitions:        1st  partition (810 out of 831GB are being used) for Timemachine backups       2nd partition (80 out of 100GB are being used) as Bootdisk Si

  • Time Capsule / Airport Extreme: What's in the 7.3.2 firmware ??

    Hi Yes, I read bug-fixes, but which ??? Didn't Apple post a list or what ?