troubleshooting Question

Count down timer

Avatar of sargent240
sargent240Flag for United States of America asked on
9 Comments2 Solutions640 ViewsLast Modified:
I am writing an application to put a basketball scoreboard on a big screen TV.  I am having a little trouble with the clock.  I have written a count down timer that works fine but I can't stop the count if a team takes a time out.  Can someone help me with the code that will allow me to start and stop the clock.  I have a socket for communicating between two computers, one is attached to the big TV and the other is the machine use to control the scoreboard machine.  I connect through a socket and send commands to the scoreboard machine like "startClock" to start it and I would like to sent "stopClock" to stop it and then "startClock" once again to resume.  I have the communications working fine and when I send "startClock" to the scoreboard machine the clock starts as it should.  Any ideas how to toggle it on and off.  The timer code is below and I start it with:

            CountDownTimer c = new CountDownTimer(0, 8, 0);

It starts counting down from 8 minutes;


    public class CountDownTimer implements ActionListener {
    private long count;
    private DateFormat df;
    private javax.swing.Timer t;

    public CountDownTimer(int hours, int minutes, int seconds) {
      // suppose to show as in 01 HR 30 MIN 30 SEC.
       count = 0;
       t = new javax.swing.Timer(1000, this);

      Calendar cal = Calendar.getInstance();
      cal.set(Calendar.HOUR_OF_DAY, hours);
      cal.set(Calendar.MINUTE, minutes);
      cal.set(Calendar.SECOND, seconds);
       count = cal.getTime().getTime();
      df = new SimpleDateFormat("mm:ss");

    public void actionPerformed(ActionEvent e) {
      // suppose to countdown till OO HR 00 MIN 00 SEC

      count -= 1000;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros