Showing a Timer as it runs...

Does anyone know how to display a Timer as it runs....
For a card game, a person's score will decrement every 10 seconds... but I want to show the time running from the start of the game until the end.
I have a labe set up, and I initiated a swing Timer with an ActionListener that uses setText for the label but I dont see any kind of getCurrentTime() method or something that will make it look like this:
Time of Game: 00:00
Any ideas?

Is this getting on the right track?
   import java.io.*;
   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
    public class Scoreboard extends JPanel
      private int moves,score;
          private long startTime;
      private JLabel movesLabel,scoreLabel,timeLabel;
      private Timer timer;
      private TimerListener timerlistener;
       public Scoreboard()
         moves = 0;
         score = 0;
         startTime = System.currentTimeMillis();
         timerlistener = new TimerListener();
         timer = new Timer(100,timerlistener);
         timer.start();
         movesLabel = new JLabel("Number of Moves: " + moves);
         scoreLabel = new JLabel("Score: " + score);
         timeLabel = new JLabel("Time: " + timer.toString());
         makePanel();
       private class TimerListener implements ActionListener
          public void actionPerformed(ActionEvent e)
            timeLabel.setText("Time: " + (startTime - System.currentTimeMillis()));
            setScore(-1);
            try
               Thread.sleep(10000000); // sleep so we have time to see the action occur
                catch(Exception exception)
       private void makePanel()
         add(movesLabel);
         add(scoreLabel);
         add(timeLabel);
       public void addMove()
         moves++;
         movesLabel.setText("Number of Moves: " + moves);
       public void setScore(int add_sub)
         if(add_sub==1)
            score+=100;
            scoreLabel.setText("Score: " + score);
         else if(add_sub==-1)
            if(score>=25)
               score-=25;
               scoreLabel.setText("Score: " + score);
            else
               score=0;
               scoreLabel.setText("Score: " + score);
   }

Similar Messages

  • Element showing Multiple times in SOE.

    Hi,
    I have added one element called 'Basic' one time only in element Entries. But it is showing 2 times in SOE report and Run Results also.
    How to remove that. Pl. help.
    Thanks in advance.

    The Element was processed multiple times in the Payroll run and hence you can see the element twice in the Run Results. The possible reasons could be
    1. Element was prorated.
    How to check : Check whether the Start Date and End Date were populated in the run results screen for the two entries of the element.
    2. Multiple Element entries were created for the Element which is ruled out as you confirmed that there are no multiple element entries.
    3. Run results were triggered due to Indirect Results.
    you need to fire some queries to find out this.
    select * from pay_element_entries where element_entry_id in (select source_id from pay_run_results where run_result_id in (<id1>,<id2>) )
    where id1 and id2 are run_result_ids of the two run result entries for the element.
    Performing above checks should give you the reasons.
    Regards,
    Sharath

  • When using my ipad2 in calendar landscape, month mode, I now see my end time of appointments running over into the next day. (i.e. ends at 1:00am now seen on next day as one long bar). any way to hide that?

    I just updated to ios6. My month view in calendar now shows the start time and end time of appointments running over into the next day. I.E. start appointment on Friday at 5:00 pm, end it at 1:00am Saturday moring. I used to only see the one entry on Friday. Now the appointment runs across both dys showing start and ent time. Can I only show start ttme on month view as I did before?

    Wow! Sorry for all the typos!

  • I'm trying to set up a DAQ assist just to measure some voltage, how do i get the graph to start from 0 (time) every time I press run

    Hi all,
    I am trying to set up a simple DAQ assist to measure some voltages (currently a 9 volt battery to aid set up), when choosing to use a waveform chart to log the voltages the graph doesnt start from 0 (time seconds) how do I do this and get it to reset every time I press run or even stop.
    What I want to see at the end is a chart for the full lenght of the test showing voltage against time in seconds.
    Any ideas peeps
    many thanks
    Shane

    Hi Shane,
    Look at this VI
    Here, I clear the chart before running the VI, using a 'history data' property node ( i pass an empty array to clear it)
    In effect, each time you run the VI, the chart will begin at 0:00
    Hope this helps
    Regards
    Dev
    Attachments:
    chart_start.vi ‏20 KB

  • My iMac, OS 10.7.5, is abnormally slow on start-up, taking many minutes for my password sign-in window to show up.  I've run Disk Permissions and have verified my hard drive and all is in order.  What do I do to start up my Mac in a normal manner?

    My iMac, OS 10.7.5, is abnormally slow on start-up, taking many minutes for my password sign-in window to show up.  I've run Disk Permissions and have verified my hard drive and all is in order.  What do I do to start up my Mac in a normal manner?

    If you have more than one user account, these instructions must be carried out as an administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Enter "BOOT_TIME" (without the quotes) in the search box. Note the timestamps of those log messages, which refer to the times when the system was booted. Now clear the search box and scroll back in the log to the last boot time when you had the problem. Select the messages logged after the boot, during the time something abnormal was happening. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    For example, if the problem is a slow startup taking three minutes, post the messages timestamped within three minutes after the boot time, not before. Please include the BOOT_TIME message at the beginning of the log extract.
    If there are runs of repeated messages, post only one example of each. Don’t post many repetitions of the same message.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    Still in Console, look under System Diagnostic Reports for crash or panic logs, and post the entire contents of the most recent one, if any. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • Why do my MacAir and iPhone show different times?

    I have a MacAir running OSX Yosemite. I also have an iPhone 6. I get both to update the times shown on their clocks automatically. Last month, there was a 2 minute difference between the two; now there is a 3 minute difference. (the MacAir is always ahead) This might sound like a tiny issue but I use my MacAir for presentations and have my phone showing the time fullscreen too - to ensure I keep exactly to time. So it's quite off-putting to have two different times showing.
    Any idea how I can get them in synch with each other?
    Many thanks!
    James

    I have a MacAir running OSX Yosemite. I also have an iPhone 6. I get both to update the times shown on their clocks automatically. Last month, there was a 2 minute difference between the two; now there is a 3 minute difference. (the MacAir is always ahead) This might sound like a tiny issue but I use my MacAir for presentations and have my phone showing the time fullscreen too - to ensure I keep exactly to time. So it's quite off-putting to have two different times showing.
    Any idea how I can get them in synch with each other?
    Many thanks!
    James

  • HT4628 my powerbook g4 os x 10.5.8 leopard is showing-Connection time out while connecting to the wifi.however it showing all available wifi connections around but not connecting it..however ethernet is working

    Problem while connecting with Wi-Fi,
    When i am connecting my powerbook g4 leopard  to any Wi-fi connection it showing -Connection time out, however Ethernet is working .I have updated all softwares but still same problem.

    It's possible that either the internal AirPort Extreme card or the antenna is faulty or has failed.
    One last thing to try before going with another Wi-Fi solutions is to the following:
    Try the following, in order, until (hopefully) resolved:
    1a. Delete Preferred Network(s)
    System Preferences > Network > AirPort > Advanced > AirPort tab
    Under "Preferred Networks," delete the network(s) you regularly use from the list.
    1b. Delete AirPort Keychain Entries
    Launch the "Keychain Access" application located in Applications/Utilties.
    Click on the "Kind" filter at the top, and look for any "AirPort network password" entries...and delete them.
    1c. Add Preferred Network(s)
    System Preferences > Network > AirPort > Advanced > AirPort tab
    Add the preferred network(s) using the "+" button.
    Restart or log out then back in.
    2. Move System Configuration Files
    (Note: You will have to reestablish your network connections settings.)
    Go to /Library/Preferences
    Move the SystemConfiguration folder to the desktop.
    Restart your Mac. (Note: OS X will rebuild the files that are now sitting on your desktop. If this doesn't resolve the issue, you can move the folder back to it's original location.)
    3. Run the Disk Utility to repair Disk Permissions.
    Restart or log out then back in.
    4. Turn off the Mac OS X Firewall
    System Preferences > Sharing > Firewall
    Click the "Stop" button.
    5. Create a New User Account
    System Preferences > Accounts
    Click "+" to add a new account
    Log off, then log back on with the new user account.
    Try connecting with the AirPort.
    If none of these help resolve the issue, you may want to consider getting a USB wireless adapter to replace both the internal card and antenna. One such vendor of these adapters is Other World Computing (OWC).

  • Logviewer 1.14 showing incorrect times, and other issues.

    Couple of issues with running LogViewer, wondering if anyone can help.
    First, and seems to be the most frustrating, is that the LogViewer screen is showing incorrect times for the events. I am in Mountain Time zone in the US, which is GMT-7. When looking at the log from a web browser, my router is displaying the correct time. The text file that LogViewer saves on the local computer shows the same correct time. The LogViewer screen, however, shows a time 7 hours into the future. IE, if I type out the log from a DOS window, the last event will say something like "Mar 28 1:15:05 2008", but that same event number will be listed on the logviewer screen as "Mar 28 8:15:05" Any ideas on what may be wrong and how to correct it?
    Second, all events seem to be grouped exactly 3 minutes apart. I realize this is probably an effect of the router sending the information every three minutes. Anyone know of a way of changing that period?
    Hm, just noticed a third, but very minor issue. The text file written has the wrong day of week on it. It's listing Mar 28 2008 as a Wednesday...
    Thanks in advance for any advice.
    OK, the tech info. I am running LogViewer 1.14 on a Windows XP machine, contacting an WRT55AG with firmware 1.20. The connection is through a Cat 5 cable, not through the wireless.

    Couple of issues with running LogViewer, wondering if anyone can help.
    First, and seems to be the most frustrating, is that the LogViewer screen is showing incorrect times for the events. I am in Mountain Time zone in the US, which is GMT-7. When looking at the log from a web browser, my router is displaying the correct time. The text file that LogViewer saves on the local computer shows the same correct time. The LogViewer screen, however, shows a time 7 hours into the future. IE, if I type out the log from a DOS window, the last event will say something like "Mar 28 1:15:05 2008", but that same event number will be listed on the logviewer screen as "Mar 28 8:15:05" Any ideas on what may be wrong and how to correct it?
    Second, all events seem to be grouped exactly 3 minutes apart. I realize this is probably an effect of the router sending the information every three minutes. Anyone know of a way of changing that period?
    Hm, just noticed a third, but very minor issue. The text file written has the wrong day of week on it. It's listing Mar 28 2008 as a Wednesday...
    Thanks in advance for any advice.
    OK, the tech info. I am running LogViewer 1.14 on a Windows XP machine, contacting an WRT55AG with firmware 1.20. The connection is through a Cat 5 cable, not through the wireless.

  • Check Scan for NI435X and elapsed time doesn't run in loop

    Dear all Labview Experts
    i have 2 questions
    (1) i written program with Check Scan for NI435X (input to no of scan to NI 435X read ) and one with only NI435X read( to read in voltage) with constant input to no of  scan,
    the data i obtained is attached in 2 doucments; With Check Scan and without check scan ( the left column is temperature read in ( a formula is used to convert volt to temperature, right column is time)
    strangely the program with check scan shows values in negative ==> Voltage read in is 0, strange, why is this so??? and why is there a diff?? Hope u understand my question
    (2) For elapsed time, i want to find the total elapsed time for the whole program as well as individual cases,  there is no "running"  elapsed time or individual running time,
    what happen is that when the each case end, the time will jump (e.g. from 0 at start, it will change to 5.35 at end of case) , is there any where to make the time run, i need it because some case required
    c
    ondition such as case will move to next after 5 seconds, but if above case happen, the vi will only stop if i put >= 5 rather than just place = 5
    hope u understand,
    does it help if i placed the condition as another loop , will it mean the same things
    Attach are vi and some doucments, however as my vi contains PID tool kit as will as ni435x ni DC power which cannot be opened if you do
    not have these kits.......however mayb u can help to look at the portion of timing as this is the main problem i faced now.........
    Hope it is not too confusing for you to understand me...........
    i can only attach max 3, the next post i will attach 2 vis...........
    Attachments:
    Picture of check scan and without.rtf ‏15 KB
    With Check Scan.txt ‏4 KB
    Without Check Scan.txt ‏1 KB

    Thks Brian
    Attached are 3 VIs
    1.the first vi is the one with the check scan
    2. the next two vi the only diff is the placement of the where i put the elapsed time and time of each case.........(without check scan)--the first
    one is within the big loop, the other outside  big loop -- the purpose i did this is because when i run the vi with the timing in the big loop, the timing does not run continuously but "skip". for e.g. Denature time: from 0 . it jump to 5.15s without showing the running.............
    i will attached another 2 vi s in my next attachment
    Hope this clarifies a bit
    your help is really appreciated
    thks
    Attachments:
    PCR Control_State Machine_4 channel_Timing within Loop.vi ‏438 KB
    PCR Control_State Machine_4 channel_with_check scan.vi ‏443 KB
    PCR Control_State Machine_4 channel_Timing outside of loop.vi ‏442 KB

  • MD04 dates not showing lead time scheduled dates

    Hi experts,
    In my MD04 screen, dates are not showing lead time scheduled dates (showing only basic dates scheduling) even after MRP run with lead time scheduling.
    Please let me know if there is a way that the date column in MD04, shows the finish date from lead time scheduling.
    thanks
    Jay

    Hello
    Production dates are not displayed on MD04.
    You can include additional fields on MD04 using a BAdI and you can use your own logic to add the production dates.
    You will find the relevant BAdI on the following document:
    BAdIs for MRP
    BR
    Caetano

  • How can I modify the High Speed Data Reader VI to show correct time information in x-axis?

    I am just a beginner learning the LabVIEW programming currently.
    I have a PXI 6115 DAQ card and have to make a hardware timed acquisition VI for maximum performance. Thus I use the High Speed Data Logger VI for data acquisition.
    However, when I read my data by using the High Speed Data Reader VI, it doesn't show its correct time information in the graph.
    How can I modify the High Speed Data Reader VI to show correct time information in x-axis?
    I hope you can explain easily because I am a beginner.

    First, I couldn't seem to find that example either on computer or on the NI sites.
    The problem that we're running into is stated in the article that I pointed to - when real time VIs are running, then the OS will stop updating the OS clock. TO us it looks like the clock is losing time. There is a hardware clock on the PXI and it is read only during boot up to set the OS clock. Our discussions with NI have not led to a solution for this problem without checking the time on start and then checking the tick count (which does not lose time) and calculating what the current time is. No access to the hardware clock is supplied.
    We're still working on a simpler way to get accurate time.
    Rob

  • How do I "show event times" on iCal Version 7.0?

    I need to see event times in my month view on iCal, but there is no box to check in iCal Preferences that allows me to select "Show Event Times" as is suggested online. Can anyone help? I am running iCal Version 7.0 on my Mac OS X (10.9.4) system. Thanks!

    Hi,
    You can find duplicates on iTunes 11.0.5.  I believe there was a problem with iTunes 11.0.0 but was fixed.
    Jim

  • Adobe DNGConverter 8.1 is showing multiple time as a device

    Adobe DNGConverter 8.1 is showing multiple time as a device on my iMac running OSX 10.9.  Today it shows 18 times.  I have not launched any Adobe software today. 

    I am Windows, so I have ZERO information on how you tell a Mac not to load software automatically

  • Problems with Photoshop CS2 I originally purchased this software several years ago. At time I was running Microsoft Windows XP. This computer recently was replaced with  a Dell running Windows 8.I reloaded my CS2 on this computer & it ran fine with a few

    Problems with Photoshop CS2
    I originally purchased this software several years ago. At time I was running Microsoft Windows XP.
    This computer recently was replaced with a Dell running Windows 8.I reloaded my CS2 on this computer & it ran fine with a few exceptions as follows;
    when the software comes up initially I get a message that says “could not complete your request because of program error”. Hitting OK allows me to continue using the software .
    When I try to activate a function using CTLR or ALT keys I get this message “required application failed to load and the product cannot continue. Please reinstall the application”. This causes the application to abort.
    Reloading my CS2 continues to generate the same messages when I depress the CTLR or ALT keys.

    Your original copy is obsolete and Adobe is offering a free replacement you are entitled to. Download and use that and that should clear it up for you.
    https://helpx.adobe.com/x-productkb/policy-pricing/creative-suite-2-activation-end-life.ht ml
    Download this copy of CS2 and use the serial number provided next to the download link.

  • I am suddenly unable to open mail from the dock. dock shows mail is up and running, but stamp does not respond when clicked, and will not quit. help?

    I am suddenly unable to open mail from the dock. dock shows mail is up and running, but stamp icon does not respond when clicked, there is no mail window opened, and will not quit. when double clicked, get new mail is not an option and I get no response with other actions.
    I am retrieving mail on my phone with no problem. this just began happening, no updates or problems with anything else.
    help?

    command-option-esc keys and force quit Mail. Then relaunch.

Maybe you are looking for