Count up timer needed please.

hi there
I have seen the countdown timer sample in this forum, i am just wondering if there is a count up timer, and the start and stop are controlled by its using class, some thing like a game, and when game starts, the timer starts, when the game ends, the timer ends as well. thank you.

Here is a counter based on the system clock:
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CountUpLabel extends JLabel{
     javax.swing.Timer timer;
     long startTime, count;
     public CountUpLabel() {
          super(" ", SwingConstants.CENTER);
          timer = new javax.swing.Timer(500, new ActionListener() { // less than or equal to 1000 (1000, 500, 250,200,100) 
               public void actionPerformed(ActionEvent event) {
                    if (startTime == -1) {          
                         count = 0;               
                         startTime = System.currentTimeMillis();
                    else {
                         count = System.currentTimeMillis()-startTime;
                    setText(getStringTime(count));
     private static final String getStringTime(long millis) {
          int seconds = (int)(millis/1000);
          int minutes = (int)(seconds/60);
          int hours = (int)(minutes/60);
          minutes -= hours*60;
          seconds -= (hours*3600)+(minutes*60);
          return(((hours<10)?"0"+hours:""+hours)+":"+((minutes<10)?"0"+minutes:""+minutes)+":"+((seconds<10)?"0"+seconds:""+seconds));
     public void start() {
          startTime = -1;
          timer.setInitialDelay(0);
          timer.start();
     public long stop() {
          timer.stop();
          return(count);
     public static void main(String[] args) {
          JFrame frame = new JFrame("Countdown");
          CountUpLabel countUp = new CountUpLabel();
          frame.getContentPane().add(countUp, BorderLayout.CENTER);
          frame.setBounds(200,200,200,100);
          frame.setVisible(true);
          countUp.start();
And here is a simplest counter :
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SimpleCountUpLabel extends JLabel{
     javax.swing.Timer timer;
     int count = 0;
     public SimpleCountUpLabel() {
          super(" ", SwingConstants.CENTER);
          timer = new javax.swing.Timer(1000, new ActionListener() {
               public void actionPerformed(ActionEvent event) {
                    count++;
                    setText(getStringTime(count));
     private static final String getStringTime(int sec) {
          int seconds = sec;
          int minutes = (int)(seconds/60);
          int hours = (int)(minutes/60);
          minutes -= hours*60;
          seconds -= (hours*3600)+(minutes*60);
          return(((hours<10)?"0"+hours:""+hours)+":"+((minutes<10)?"0"+minutes:""+minutes)+":"+((seconds<10)?"0"+seconds:""+seconds));
     public void start() {
          count = 0;
          setText(getStringTime(count));
          timer.setInitialDelay(1000);
          timer.start();
     public long stop() {
          timer.stop();
          return(count);
     public static void main(String[] args) {
          JFrame frame = new JFrame("Countdown");
          SimpleCountUpLabel countUp = new SimpleCountUpLabel();
          frame.getContentPane().add(countUp, BorderLayout.CENTER);
          frame.setBounds(200,200,200,100);
          frame.setVisible(true);
          countUp.start();
I hope this helps,
Denis

Similar Messages

  • "Count Up" Timer (& Need to Display Different Time Denomination)

    This is a tough one, so any help or suggestions with just
    where to start looking would be fantastic!
    I am an academic researcher using authorware for my
    dissertation. In my experiment, I need to make my participants
    experience a time delay. I want to display something on the screen
    that shows the passage of time (i.e., "counts up") in days, even
    though they are experiencing it in seconds. For example, while the
    participant is experiencing the delay, I want to have the screen
    display something like, "It has been 2 days since you have
    contacted your partner". I would like to have the "2" change to a
    "3" after 10 seconds, and then to a "4" after another 10 seconds,
    etc. Eventually after several days have passed, they will move onto
    a new screen. I have already used systemseconds to put a time delay
    into a different authorware piece (i.e., so that participants could
    only access something after a certain amount of time), so I know
    how to do that. However, I am not even sure where to start with
    displaying the "count up", particularly displaying it in such a way
    that it doesn't actually show the number of seconds that have
    passed, but a corresponding amount of time.
    If this doesn't make sense or needs clarification please let
    me know. I appreciate any and all advice!!
    Thanks!!
    Tamara

    You can make a counter for 1/10ths of a second pretty easy.
    Calc icon
    StartTimer := SystemSeconds
    DisplayIcon -
    It's been {INT((SystemSeconds - StartTimer) / 10)} days since
    you contacted
    your partner.
    Then you build an interaction with a time limit response that
    triggers after
    the amount of time you want. That response will trigger the
    movement to the
    new page.
    Mike
    "alleyshea" <[email protected]> wrote in
    message
    news:g46ged$rli$[email protected]..
    > This is a tough one, so any help or suggestions with
    just where to start
    > looking would be fantastic!
    >
    > I am an academic researcher using authorware for my
    dissertation. In my
    > experiment, I need to make my participants experience a
    time delay. I
    want to
    > display something on the screen that shows the passage
    of time (i.e.,
    "counts
    > up") in days, even though they are experiencing it in
    seconds. For
    example,
    > while the participant is experiencing the delay, I want
    to have the screen
    > display something like, "It has been 2 days since you
    have contacted your
    > partner". I would like to have the "2" change to a "3"
    after 10 seconds,
    and
    > then to a "4" after another 10 seconds, etc. Eventually
    after several
    days
    > have passed, they will move onto a new screen. I have
    already used
    > systemseconds to put a time delay into a different
    authorware piece (i.e.,
    so
    > that participants could only access something after a
    certain amount of
    time),
    > so I know how to do that. However, I am not even sure
    where to start with
    > displaying the "count up", particularly displaying it in
    such a way that
    it
    > doesn't actually show the number of seconds that have
    passed, but a
    > corresponding amount of time.
    >
    > If this doesn't make sense or needs clarification please
    let me know. I
    > appreciate any and all advice!!
    >
    > Thanks!!
    >
    > Tamara
    >

  • I need a count "UP" timer for a client.

    I have kind of a strange request, but it's from a strange client so it's not surprising.
    The client needs a counting UP timer, not a count DOWN timer, so please don't refer me to that widget, I already used it.
    The original countdown timer has expired, so now she wants a timer that will count the days, hours, minutes & seconds SINCE that timer expired.
    Website splash page: http://www.theapocalypse.ca so you can see what I mean.
    Is it possible to "crack" the existing widget and just "reverse" it, or is there something I can build in edge animate that will work?
    I know, WEIRD, but hey, a paycheque is a paycheque.
    Thanks guys!

    You may try this : http://www.tickcounter.com/countup/widget
    Thanks,
    Sanjit

  • HT4061 need help with my iphone 4 i try to update last five  days but after updating to 6.1.2  it says that    We're sorry, we are unable to continue with your activation at this time. Please try again later, or c

    need help with my iphone 4 i try to update last five  days but after updating to 6.1.2  it says that
    We're sorry, we are unable to continue with your activation at this time. Please try again later, or c

    If the iPhone was hacked and unlocked via unofficial means, it has become locked again. Insert original SIM in the phone to activate with iTunes.

  • I made upgrade for IOS to 7.04 but my iphone is second hand and when iphone need to make activation ,i don't have the apple ID so my iphone didn't work from this time so please help me urgent

    I made upgrade for IOS to 7.04 but my iphone is second hand and when iphone need to make activation ,i don't have the apple ID so my iphone didn't work from this time so please help me urgent.

    There isn't one.
    amrzaky wrote:
    I can't contact with previous owner s i need another solutoin
    The Apple ID and Password that was Originally used to Activate the iDevice is required.
    If you cannot get this information from the seller
    Removing a device from a previous owner’s account
    You need to return the Device for a refund, as you will not be able to re-activate it.

  • Please how can I restore my ipod touch 2g from a firmware that I own already on my computer and without any time need to download via itunes

    please how can I restore my ipod touch 2g from a firmware that I own already on my computer and without any time need to download via itunes

    You should probably disable the autosync functionality first by going to Edit -> Preferences, clicking the Devices tab, and enabilng the prevent iPods,iPhones, and iPads from automatically syncing option.
    Next, authorize the new computer with your iTunes Account.  In iTunes, choose Store -> Authorize This Computer and enter in the correct credentials.
    If possible, either copy a backup file from your old computer to your new one or create a new backup of your iPod in iTunes before letting it sync.  To do this, right->click on your iPod Touch from under the Devices section in the left hand pane of iTunes and choose Backup. You might also want to take a look at this article to see what it all included in the backup.
    http://support.apple.com/kb/ht1766
    Now onto synced content such as music, videos, photos, etc.  For iTunes purchases you can copy them back into iTunes by choosing File -> Transfer Purchases.  For all other nonpurchased iTunes content, see this older post from another forum member Zevoneer covering different software availbable to assist you with this task.
    https://discussions.apple.com/thread/2452022?start=0&tstart=0
    Once the backup has been made and all other synced content such as music, videos, and photos are back in your iTunes library, restore your iPod from that backup you made earlier.  Here is more on backing up and restoring your iPod.
    http://support.apple.com/kb/ht1414
    B-rock

  • Server Autorestart after software updates at a specific time - advice needed please

    Hi
    I am implementing server software updates.  I want them to install updates and restart on the 2nd Thursday of the month.
    so in theory:
    collection 1 restarts between 1am and 2am
    collection 2 restarts between 3am and 4am
    Collections 1 and 2 will look at the same software update groups of baseline and production and the updates will be manually put into these groups before the restart date.  There will be a test server group that will use a automatic deployment
    rule and install and restart on patch Tuesday as well which is where the updates will come from.  Days will vary but I cant quite grasp the initial implementation of the timed install and restarts.
    How can I best accomplish this?
    Thank You

    Yeah sorted thanks, im not really working toward firm dates as yet I just wanted to know if it can be done but my times needed to be wider as the system may run out of time before being able to process all the servers in the given window space.

  • Bulk Collect taking more time. Please suggest .

    I am working on oracle 11g
    I have one normal insert proc
    CREATE OR REPLACE PROCEDURE test2
    AS
         BEGIN
         INSERT INTO first_table
         (citiversion, financialcollectionid,
         dataitemid, dataitemvalue,
         unittypeid, financialinstanceid,
         VERSION, providerid, user_comment,
         userid, insert_timestamp,
         latestflag, finalflag, filename,
         final_ytdltm_flag, nmflag , partition_key
         SELECT citiversion, financialcollectionid,
         dataitemid, dataitemvalue, unittypeid,
         new_fi, VERSION, providerid,
         user_comment, userid,
         insert_timestamp, latestflag,
         finalflag, filename, '', nmflag,1
         FROM secon_table
         WHERE financialinstanceid = 1
    AND changeflag = 'A'
    AND processed_flg = 'N';
         END test2;
    To impove performance i have normal insert into convert it to bulk collect :
    CREATE OR REPLACE PROCEDURE test
    AS
    BEGIN
         DECLARE
         CURSOR get_cat_fin_collection_data(n_instanceid NUMBER) IS
         SELECT citiversion,
         financialcollectionid,
         dataitemid,
         dataitemvalue,
         unittypeid,
         new_fi,
         VERSION,
         providerid,
         user_comment,
         userid,
         insert_timestamp,
         latestflag,
         finalflag,
         filename,
         nmflag,
                   1
         FROM secon_table
         WHERE financialinstanceid = n_instanceid
    AND changeflag = 'A'
    AND processed_flg = 'N';
         TYPE data_array IS TABLE OF get_cat_fin_collection_data%ROWTYPE;
         l_data data_array;
         BEGIN
         OPEN get_cat_fin_collection_data(1);
         LOOP
         FETCH get_cat_fin_collection_data BULK COLLECT
         INTO l_data limit 100;
         FORALL i IN 1 .. l_data.COUNT
         INSERT INTO first_table VALUES l_data (i);
    EXIT WHEN l_data.count =0;
         END LOOP;
         CLOSE get_cat_fin_collection_data;
         END;
         END test;
    But bulk collect is taking more time.
    below is the timings
    SQL> set timing on
    SQL> exec test
    PL/SQL procedure successfully completed
    Executed in 16.703 seconds
    SQL> exec test2
    PL/SQL procedure successfully completed
    Executed in 9.406 seconds
    SQL> rollback;
    Rollback complete
    Executed in 2.75 seconds
    SQL> exec test
    PL/SQL procedure successfully completed
    Executed in 16.266 seconds
    SQL> rollback;
    Rollback complete
    Executed in 2.812 seconds
    Normal insert :- 9.4 second
    Bulk insert:- 16.266 seconds
    I am processing 1 lakh rows.
    Can you please tell me the reason why bulk collect is taking more time. ? According to my knowledge it should take less time.
    Please suggect do i need to check any parameter?
    Please help.
    Edited by: 976747 on Feb 4, 2013 1:12 AM

    >
    Can you please tell me the reason why bulk collect is taking more time. ? According to my knowledge it should take less time.
    Please suggect do i need to check any parameter?In that case, your knowledge is flawed.
    Pure SQL is almost always faster than PL/SQL.
    If your Insert into Select is executing slow, then it is probably because the Select statement is taking long to execute. How many rows are being Selected and Inserted from your query?
    You might also consider tuning the Select statement. For more information on Posting a Tuning request, read {message:id=3292438} and post the relevant information.

  • Help needed please, with Iphone stuck with apple picture and progress bar after software update attempted

    Help needed please, everytime I try to update the software version on my iphone it comes up with a message saying it could not be completed and is now frozen with the apple picture and progress bar on it. Do I unplug it and hope the macbook pro sees it again, I also stupidly did not back up before starting the download which I realise I will have to go back to the previous back up. This keeps happening, everytime I do this type of update, I'm starting to think I should just give up on updating my software on the Iphone. I thought it was happening because I was using a window based computer to do the updates, this time I used my Macbook Pro. Please somebody help

    ljm17 wrote:
    ...This keeps happening, everytime I do this type of update, I...
    Then you should know what you need to do... If you don't remember...
    See Here  >  http://support.apple.com/kb/HT1808

  • I am trying to reinstall Dreamweaver CS3 from the CD after having computer issues.  Now getting error "You can only install one Adobe product at a time.  Please complete the other installation before attempting to install ......."  There is no other Adobe

    I am trying to reinstall Dreamweaver CS3 from the CD after having computer issues.  Now getting error "You can only install one Adobe product at a time.  Please complete the other installation before attempting to install ......."  There is no other Adobe product installing.  I have used the Adobe Cleaner Tool many times and uninstalled other Adobe Products but neither has worked.  I have uninstalled/reinstalled this CD version of Dreamweaver several times when changing computers and after having computer issues. A google search of the problem suggested it may be an error related to the number of times I can reinstall this product due to licensing issues.  Please help.

    A google search of the problem suggested it may be an error related to the number of times I can reinstall this product due to licensing issues.
    Absolutely not. You are misinterpreting things. The activation check never happens when just running the installer, only much later. It means what it says - there is another "install" pending/ active on your system, meaning somewhere there is an (invisible) process still blocking things. Either way, since you haven't provided any real technical info, we can't advise specifically. if you are on Windows, you may want to check your task manager and terminate any setup.exe and msiexec.exe processes plus potentially may need to manually fix/ delete some registry keys. For anything beyond that you will have to be much more specific.
    Mylenium

  • I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro.... The operation can't be completed because an unexpected error occurred (error code -50)

    I keep on getting this error when i try to copy files to my 2T Time Capsule, Please help im running out of space on my MacBook Pro....
    The operation can’t be completed because an unexpected error occurred (error code -50)

    I would get an external drive today and copy all your stuff off the TC.. forget trying to load more onto it. There is a good chance after 3years (A 2TB should be only about 2years tops), the disk or the TC itself is on the way out. Do it immediately. If TM is also failing to backup you need to recognise symtoms of impending doom.
    Unfortunately the error messages are archane and it is hard to discover their meaning.
    You also cannot verify a network drive.. you can verify the TM sparsebundle though so do that.
    A5. http://pondini.org/TM/Troubleshooting.html
    Reboot the whole network from off.. certainly if you run later OS it can simply lose the drive..
    If you still fail to be able to copy to the TC.. then get that external and copy off it. Tell us if you can do that.

  • App Store says, "Tuner! and 4 other apps could not be downloaded at this time. Please try again later." How may I appease the Store?

    App Store says, "Tuner! and 4 other apps could not be downloaded at this time. Please try again later."
    How may I appease the Store? The message first appeared a couple of weeks ago and seems to reappear every time I download something from the App Store, be it an update or a new app. I tried re-downloading and re-deleting "Tuner!" (this is the only one whose name I can see), but to no avail. I even tried hiding a whole load of apps from my Purchased list (including Tuner!) in the hope that the five offenders would GO AWAY and stop waiting around being nuisances ;) I haven't noticed them slowing down/stopping my other downloads, so I never paid the pop-up notice much attention, but it is starting to bug me now.
    Thank you if you can help.

    I have been getting the message from time to time over the last couple of weeks.  I just click through, and the download haooens anyway.      The other day I looged onto my accout in apple.com, and it simply wanted me to verify the ccv on the credit card.    
    I am glas your solution worked, but I am not sure you needed to do a full wipe and reinstall.   There is some goofy stuff going on with the store, but nothing you can't get by.

  • I am getting the error "We're sorry we cannot complete your request on the iTunes store at this time. Please try again later." on both my iPhone and iTunes on my computer. What is wrong with iTunes? Is the server down???

    I am getting the error "We're sorry we cannot complete your request on the iTunes store at this time. Please try again later." on both my iPhone and iTunes on my computer. What is wrong with iTunes? Is the server down or what? I need to download some things and update some apps...

    I've been getting the same message for like an hour now.  Since everything was working fine a few hours ago, and nothing changed on my end before it stopped working, I'm guessing it's something on Apple's end.  They probably already know about it by now, and are hopefully working on fixing it, so there's probably not much we can do but wait for them to fix it.

  • How to estimate the time needed for unicode conversion

    Experts:
    I am going to perform an upgrade from 46C (non-unicode) to ECC6/EHP4.
    In the action plan , it's hard to estimate the time needed for unicode conversion.
    We do not have a sandbox to benchmark that time.
    Could you please help share your experience here?
    Thanks!!

    Hi,
    usually it is very hard to estimate a proper time.
    There are some hints to get a rough feeling (SAP note 857081 and [SMP link|http://service.sap.com/~form/sapnet?_SHORTKEY=01100035870000380759&_OBJECT=011000358700001279022010E] ).
    However please note that SAP highly recommends to do a Sandbox conversion - otherwise there is a high risk that the PRD conversion will take (much) longer than expected.
    Best regards,
    Nils Buerckel

  • The server was unable to save the form at this time. Please try again

    Having created a new custom list (even with only a text field) I am unable add new items to the list - the error message is Unexpected
    response from server. The status code of response is '0'. The status text of response is ''. when in 'quick edit'.
    If I try to add or modify an item in the list by clicking 'add new item' I get "The
    server was unable to save the form at this time. Please try again."
    I have restarted the Sharepoint Search Host Controller server but to no avail. I have 24Gb RAM for this server so it's not a
    memory issue (8Gb available). I have also tried from various browsers including Chrome and Safari - still the same error message.
    This error only occurs on lists. I can edit document properties in a library and have no problems with calendar entries.
    There are no entries in the event viewer, so where do I need to begin looking to find out what is (or rather is not) happening?

    One thing I noticed in SP 2013 is that if your list has unique permissions and a user/group has permissions only on that list and has limited or no access at the site level, then you run into this error: "The server was unable to save the form at this time.
    Please try again."
    This can be resolved by either giving that user/group atleast read access at the site level or in my case I had to create a new permission set (since we cant update limited access permission set) which is same as limited access but with the additional permission
    of "Use Remote Interfaces  -  Use SOAP, Web DAV, the Client Object Model or SharePoint Designer interfaces to access the Web site."
    I am not sure if this is a bug or as per design, but not allowing a user who has needed permissions at the list level but limited access at site level doesnt seem right. Never ran into this issue in prior version of SharePoint. I tested and this additional
    permission doesnt seem to violate any security at site level. But implement this at your risk. No guarantees provided and not responsible for any issues with this implementation if any.

Maybe you are looking for

  • Horizontal Menu Bar Sub Menus Go Across and Not Down

    How do I make the submenus for my horizontal menu drop down instead of going across the page in IE? It works fine in every other browser.

  • Pictures in iPhoto to be sent to a website

    Can anyone tell me how to go about sending a picture from iPhoto to a website? The picture will be seen as a thumbnail on the website (and when clicked, will open a new page with a larger view of the picture). Does the picture need to be a certain pi

  • _sans font problem or bug..!?

    while using _sans font with 11px, the edge of W is getting cut. But wen i change to 12px or 10px it works fine... ActionScript Code: <mx:TextArea id="_txt" htmlText="{txtStr.toUpperCase()}" width="600" height="200" styleName="subSectionTextStyle" />

  • Using the java.util.regex package

    I am trying to use the regex package to grep out portions of a string that match a regular expression. Some code from my class     String fileList = "1_tmp.txt 2_tmp.txt 3_tmp.txt 1_inpt.txt 2_inpt.txt 3_inpt.txt 1_out.txt 2_out.txt 3_out.txt";     S

  • Anyone actually use bluetooth with their phone?

    So i have recently discovered that the less i deal with my phone directly the better my quality of life should be. I have deleted pretty much all the bs social networking apps from my phone and try my damndst to keep my eyes off of the screen. But th