Question redarding Timer class

I have 16 buttons set to disabled initialy. And
I have a timer event listener which andomly triggers one of 16 buttons to be Enabled every 250ms. How to let this timer object to create a second Timer object
each time it enables a button. The second timer will have a delay time of 1000ms.
When it is trggered, the second timer will clear the enabled button to be disabled again.
It is just like one Enabled button's lift time is 1000ms. And there maybe more than one button lives at same time. How to handle their differnt life time?
Thank you So much!

Thank you camickr
but my program still has problems.
//Control Button Listener. This starts timer2 which is main timer to andomly
//pick a button to enable it.
     class ControlButtonListener implements ActionListener{     
          public void actionPerformed(ActionEvent evt){
          System.out.println("Game Start");
          timer2 = new Timer(2000,startPicking);//Main timer     
     timer2.start();
//Timer2 ActionListener
class Timer2Listener implements ActionListener{     
     public void actionPerformed(ActionEvent evt){
     int pick = rn.nextInt(16);
          JButton newButton = (JButton) centerPanel.getComponent(pick);
          System.out.println("Picked "+ pick);
          newButton.setIcon(iconNormal);
     centerPanel.getComponent(pick).setEnabled(true);
     int twosec = timern.nextInt(2001);
     System.out.println(twosec);
     timer2.setDelay(twosec);
//Here is where I create a second timer each time a button was
//Enabled.
     timer1 = new LifeTimeTimer(1000, stopForOneSec, pick);
     timer1.start();
     timer1.setRepeats(false);
I also have Extended Timer Class so that timer1 = new LifeTimeTimer(1000, stopForOneSec, pick); can store which button has been enabled.
and of course Timer1Listener is just for set the enabled button to disabled.
My problem here is, If there are two buttons are enabled within 1000ms
That means the first button haven't been disabled, and the second Enabled button
have already appeared. The second timer(timer1) can only have information about
the lastest button that just appeared.
Would you please help me with that?
I think I missunderstand something. Sorry for bring all the troubles.

Similar Messages

  • Formatting incoming string with date/time classes?

    Hello,
    In the software I am writing currently I am @ a certain point talking to an external device. sending requests, receiving responses.
    One of the things I find in the response is "20090429094222", as a string.
    I cannot change anything to that, thats the way I get it from the device, so thats where I'll have to start with.
    As you could probably guess this is a date and a time. Now my question. Is there a good way to format this from 20090429094222
    to
    2009-04-29 09:42:22
    using date and or time classes, not using String operations?
    Thanks in advance.

    I found a class containing 2 functions who do exactly what I need, for those intrested:
    public static Date convertStringToDate(String txtFormat, String txtDate) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            Date date =  dateFormat.parse(txtDate);
            return date;
    public static String formatDate(Date date, String txtFormat) {
            DateFormat dateFormat = new SimpleDateFormat(txtFormat);
            String txtDate = dateFormat.format(date);
            return txtDate;
        }Using them this way gives me exactly what I want:
    Date dt = DateUtil.convertStringToDate("yyyyMMddHHmmss", incomingDateSTring);
    String newDateString = DateUtil.formatDate(dt, "yyyy-MM-dd HH:mm:ss");Problem solved, thanks alot to those who gave me some explanation on the problem.

  • Combining LVOOP DVR with Asynchronous Dynamic Dispatch and Preserve Run-Time Class

    OK, the title sounds like a cornucopia of LVOOP terms.  But there's a reason.  This is in a way an extension of THIS thread.
    What I'm doing recently is creating a LVOOP approach to loading Completely Asynchronous UI elements into subpanels.  This I have combined with a global repository for the objects (which are essentially singletons with a UI functionality) which are shared via DVR, thus eliminating a lot of synchronisation headaches).
    This means that I can ahve a universal framework for launching the UI elements into a subpanel.  The changes made on the Object there are automatically reflected in the global repository.
    So far so good.
    What I don't like too much is a combination of two seemingly awkward code constructs I need in order to keep things running.
    Weird construct 1:
    I have defined a "Launch UI" function in my parent class which is Dynamic Dispatch (Allowing each object to take care of launching its own UI).  This takes a parent object DVR as a second input which I make sure is of the exact same type as the object type being invoked by using the code shown below.  The ACTUAL Type of both inputs to the launch VI within the IPE are identical.  This is guaranteed because I require each new class to override this function.
    Here I pass the DVR from outside the IPE to the "Launch" VI but the Object obtained within the IPE retains information required for DD thus ensuring that the VI called for launching the UI is identical to the ACTUAL object type in the DVR.  This works OK and by placing this weird construct WITHIN the parent class, abuse is minimised, it works fine and seems to have no major side-effects.
    So now we have a VI running asynchronously in the background which belongs to a specific object but has a DVR which it *thinks* is of a Parent Type but, because of the steps taken earlier, is actually of the same type as the object itself.
    In order to make use of the functionality defined in this actual object type, I need to continuously re-interpret the Object within the IPE as shown below.  Otherwise only the Parent functionality is available.
    If I am accessing only methods of the parent class, then the Preserve functionality is not needed.
    Is there a more elegant way to do this?  I find the net result of this code and type-juggling to be really useful and much easier to manage than the non-DVR route since the synchronisation issues disappear.  By making the IPE usage near-atomic we remove the chances of deadlock.
    All editing done in the UI of the asynchronous VI is reflected automatically in any subsequent usage of the DVR.  Even if the DVRs are not shared between VIs, this makes (for me) the headache of synchronisation easier.  If you start expanding this beyond the limits of a single VI, the benefits in Synchronisation become really huge.  You can even have multiple UI objects operating on the same data in the background without extra synchronisation needs.  The only synchronisation required is a global "Data updated" for the object in question whereby the UI elements simply update their indicators and controls from the DVR again.  This is trivial.
    Thus I am convinced that the net result of this is very beneficial.
    My question is if there's a better, safer or more "official" way to do this?
    I was about to start a new Idea for combining the "Preserve Run time Class" and the DVR Terminal of the IPE so that the casting is done automatically.  We could then have a double input to the IPE, the DVR (of base type) plus the ACTUAL Type of the object but of course returning an error if the types are incompatible.  It would be like an "Imposter" DVR input for the IPE which allows a re-interpretation of the object type.
    Would all of this go away if we allowed Dynamic Dispatch to work with DVRs?  Probably.
    Shane
    Say hello to my little friend.
    RFC 2323 FHE-Compliant
    Solved!
    Go to Solution.

    You guys rock!
    I didn't even think of casting the DVR like that.  Kinds stupid of me but I never would have thought it would work.  Cool.
    Also, Yeah, the limitation of no IPE in the Launch VI was one I spotted quite early on.  this is why my Launch VI also doesn't accept more data than is absolutely neccessara because a DVR access in that VI will of course cause a lockup.  I have the system so far now that I can have a SINGLE Launch VI (Which is NOT overridden, so the limitation refers to only a single VI now which is certainly better.
    So again guys, thanks for helping out an old newbie.  I've been around for quite a while, have made many posts but I love the way I just keep learning from others in the Forum.  This is just why I absolutely LOVE it here. 
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Hello, I have two questions on time capsule  I can only have it on my external hd files and free up my internal memory to my mac  I can use an external hard drive, in my case a lacie rugged as shared memory for my two computers

    Hello, I have two questions on time capsule  I can only have it on my external hd files and free up my internal memory to my mac  I can use an external hard drive, in my case a lacie rugged as shared memory for my two computers

    I have a mackbook pro and an iMac if I buy a time capsule 2tb airport, I can use it with time machine and what would be the best way to use it.
    There is no particular setup required for TM.. both computers will create their own backup sparsebundle which is like a virtual disk.. Pondini explains the whole thing if you read the reference I gave you.
    and how to use time capsule airport whit other external hd to use my old lacie airport with the new time capsule
    Up to you.. you can plug the external drive into the TC and enjoy really slow file transfers or you can plug it into your computer and use it as external drive.. which is faster than the TC.. and TM can include it in the backup.
    Again everything is explained in the reference.. you are not reading it.

  • How can I prevent deleted mail from ending up in "All Mail"     and "Archives"?  To my horror, I've emptied these boxes and lost all my mail from all my boxes  (and why do I need to enter this question three times?"

    How can I prevent deleted mail from ending up in "All Mail" and "Archives"? 
    To my horror, I emptied these boxes and lost all my mail from all my boxes .
    All mail also disappeared from my iPad, I suppose because they are "synched"
    (Also, no offense, but why do I need to enter this question multiple times?)
    Thanks for any thoughts.

    I'm having a similar but slightly different problem. My company just migrated to Gmail, and it's saving mail drafts every 30 seconds into my Trash folder.
    I unchecked the "Show in IMAP" preference in the Gmail settings, but my Drafts folder completely disappeared. I went back and checked it and the folder reappeared (with my drafts still in there).
    I like the idea if starting an email on my laptop and having the option of finishing it on my iPhone or iPad, so only saving Drafts locally would not be ideal.

  • I'm using a new computer and to open one website I have to answer the security questions each time saying that the site doesn't recognize this computer.

    Each time I try to open my "ubt" website, I get a message that says the site does not recognize this computer so I have to answer the security questions each time. I get the message "You are attempting to log in to your account from a computer that we do not recognize..." All other websites work just fine. The Mac store person could not figure it out. This site works on Safari, but I prefer Firefox.

    The ipod is not a backup device. The music sync is one way - computer to ipod.  The only exception is itunes purchases:  Without syncing:File>transfer Purchases
    Copy everything from your backup copy of your  old computer to your new one.

  • Why do I have to answer security questions every time I download an app

    Not sure why I have to answer my security questions every time I try to download an app? How do I change that setting?

    Contact iTunes
    Apple - Support - iTunes - Contact Us
    To reset the them:
    From a Kappy  post
    The Three Best Alternatives for Security Questions and Rescue Mail
       1. Use Apple's Express Lane.
              Go to https://expresslane.apple.com ; click 'See all products and services' at the
              bottom of the page. In the next page click 'More Products and Services, then
              'Apple ID'. In the next page select 'Other Apple ID Topics' then 'Forgotten Apple
              ID security questions' and click 'Continue'. Please be patient waiting for the return
              phone call. It will come in time depending on how heavily the servers are being hit.
         2.  Call Apple Support in your country: Customer Service: Contacting Apple for support or
              Apple ID- Contacting Apple for help with Apple ID account security. Ask to speak to
              Account Security.
         3.  Rescue email address and how to reset Apple ID security questions.
    How to Manage your Apple ID: Manage My Apple ID

  • HT5622 Will I have to awnser my security questions every time I get an app? And if so how do I get rid of them?

    Will I have to awnser my security questions every time I get an app? And if so how do I get rid of them?

    If you forgot them:
    From a Kappy  post
    The Three Best Alternatives for Security Questions and Rescue Mail
       1. Use Apple's Express Lane.
    Go to https://expresslane.apple.com ; click 'See all products and services' at the
    bottom of the page. In the next page click 'More Products and Services, then
    'Apple ID'. In the next page select 'Other Apple ID Topics' then 'Forgotten Apple
    ID security questions' and click 'Continue'. Please be patient waiting for the return
    phone call. It will come in time depending on how heavily the servers are being hit.
    2.  Call Apple Support in your country: Customer Service: Contact Apple support.
    3.  Rescue email address and how to reset Apple ID security questions.
    A substitute for using the security questions is to use 2-step verification:
    Two-step verification FAQ Get answers to frequently asked questions about two-step verification for Apple ID.

  • Timer Class in jsdk 1.4 w2000 doesn't compile

    Since this is based in the tutorial, shouldn't be a big deal but I spent the whole day looking for a solution. Please help!
    The tutorial presents this program:
    //1.3
    import java.util.timer;
    public class Problem {
    public static void main(String[] args) {
    final Timer timer = new Timer();
    timer.schedule(new TimerTask(), 5000);
    System.out.println("In 5 seconds this application will exit. ");
         public class TimerTask implements Timer {
    public void run() {
    System.out.println("Exiting.");
    timer.cancel();
    My problem starts because java.util doesn't have the timer class:
    Problem.java:2: Class java.util.timer not found in import.
    import java.util.timer;
    ^
    Now, JSDK 1.4 doesn't have timer as a package, but as a class, nevertheless, the instruction:
    import java.util.*; // instead of java.util.Timer
    doesn't compile because
    Problem.java:10: Interface Timer of inner class Problem. TimerTask not found.
    Problem.java:6: Class Timer not found in type declaration.
    I think Timer should be expressed as abstract, but how?
    I'm new in Java and feel a little frustrated...

    >
    ProblemSolved.java:3: Class java.util.Timer not found
    in import.
    import java.util.Timer;
    ^
    1 error
    Then you are not using java 1.3. You are using something before that.
    for the Timer and
    javac IteratorDemo.javaIteratorDemo.java:1: Interface java.util.Iterator of
    class IteratorDemo not foun
    d.
    public class IteratorDemo implements
    java.util.Iterator {
    ^
    1 error
    And this suggests that you are using something before 1.2.
    Just a thought...
    Windows comes with the MS version of java, which matches something like 1.1.6. It is in the path. So does you path put the jdk path first or last?

  • Using server time in  Timer Class

    Hai,
    I have develped an application(stand alone) using swings. the exe runs in all the systems in my company.
    requirement is
    --> application has to be closed at 11.59 P.M everyday.
    i did this task using Timer class. Timer class takes the system time in which the application runs. what i need is the server time. so when the application runs it has to check the server time and when the server time is equal to 11.59 PM application has to be closed.
    so how do i map the timer class to my server time?
    iam breaking my head for this for past few days. is there any way to do this?
    thanks

    1)Do you have one database in total? I mean all Java Application read and save data to this database. If so, try to get time from database by using database function. I recommend you to do this because database is central and all application share data with the database.
    2) You can still call web server in Java application. My link in last post will tell you.
    3) You can write a Java Server application for providing current server time for all your Java application. Socket technique may be used.
    Therefore, solution 1 and solution 2 look simpler than solution 3.

  • Timer class and javax.......

    Hi,
    Downloaded the latest java version to d:\download folder. The downloaded file has the name
    " j2re-1.4.2_03-wndows-i586-p.exe ". The file size was about 14.53MB. Double clicking the same installed j2re1.4.2_03 in "C:\Program Files\java\j2re1.4.2_03" folder.
    When I tried to compile Reminder.java program that comes with online Tutorial
    from within C:\Program Files\java\j2re1.4.2_03 at MS-DOS prompt, I got the error message �class java.util.Timer not found in import�.
    I also have Jdk1.1.3 in C:\jdk1.1.3 folder. When I tried to compile Reminder.java from within C:\jdk1.1.3 at MS-DOS prompt, got the same error message,
    Even after changing path variable to C:\jdk1.1.3\bin. Please help.
    Trying to compile any swing program at both DOS prompts gives error message �javax.__________ not found in import�. Can�t figure out why. Please help.
    ammukalai.

    j2re1.4 is a runtime only (ie j2re = Java Runtime Engine) It will not compile java files.
    The timer class was introduced with Java version 1.3.
    You currently have a very old version of 1.1.3.
    You need to download the j2se1.4.2 SDK - http://java.sun.com/j2se/1.4.2/download.html
    The size is closer to 50MB :-)
    Cheers,
    evnafets

  • Need to implement the timer class for 1.1

    Hi
    I am using JDK1.1 for integration with a STB.
    The timer class is not existing for 1.1.
    Where I can find an implementation code of the timer class in order
    to perform a schedule task which work with JDK 1.1
    Thanks
    Fred

    Before you look for Sun's implementation of Timer in post-1.1 versions, make sure you read the licence agreement for those versions and the copyright notice on the code. There's a good chance that by using that code you will be violating one or both of those. This may be a serious issue.
    Your other alternative is to read the API documentation for Timer (and TimerTask) and to write your own implementation. That shouldn't be too difficult.
    I doubt that you will find people actively writing open-source extensions for Java 1.1 since Java 2 has been out for nine years now. Most likely you are on your own there.

  • I have installed Adobe Reader 11.0.07 for Mac OS 10.9.3. Have asked this question numerous time without results. The problems I am having are: I cannot scroll using the side slider on downloaded PDF files, nor can I fill in fillable files. Also, and this

    I have installed Adobe Reader 11.0.07 for Mac OS 10.9.3. Have asked this question numerous time without results. The problems I am having are: I cannot scroll using the side slider on downloaded PDF files, nor can I fill in fillable files. Also, and this is extremely irritating, I cannot re-initialize the same file or initialize and another PDF file after I have initialized the first file. If you cannot help please let me know if should use an earlier  version of Reader or find anther company that has the appropriate software.

    Perhaps you missed that you started a discussion at I have OS 10.9.2 and have downloaded latest version of Reader 11. I can no longer fill in form or scroll using the side bar. and you did not respond to the last post there.

  • How to use server time in  Timer Class

    Hai,
    I have develped an application(stand alone) using swings. the exe runs in all the systems in my company.
    requirement is
    --> application has to be closed at 11.59 P.M everyday.
    i did this task using Timer class. Timer class takes the system time in which the application runs. what i need is the server time. so when the application runs it has to check the server time and when the server time is equal to 11.59 PM application has to be closed.
    so how do i map the timer class to my server time?
    iam breaking my head for this for past few days. is there any way to do this?
    thanks

    1)Do you have one database in total? I mean all Java Application read and save data to this database. If so, try to get time from database by using database function. I recommend you to do this because database is central and all application share data with the database.
    2) You can still call web server in Java application. My link in last post will tell you.
    3) You can write a Java Server application for providing current server time for all your Java application. Socket technique may be used.
    Therefore, solution 1 and solution 2 look simpler than solution 3.

  • Timer Class

    Hi
    I am using a timer delay between 2 functions, with the delay of 140ms.  One function triggers an RAW audio file thats embed into the .swf by extending the sound class.
    The problem is, that I am having slight timing issued that seem to be on a global scale.  So far I have to audio channels playing samples that are uncompressed and very short.  I have dicovered and read some adobe cookbooks on the accurateTimer() class, thats been custom built to override the Timer class functions, but I cant seem to get it to work on my set up.
    The app is a music sequencing app that will eventually have 16 channels of audio apposed to the current 2 at present.
    The cookbook is can be found here:
    http://cookbooks.adobe.com/post_Accurate_timer-17332.html
    And my code that drives the audio channels is here:
    var tempo:Number = 125.125;
    var timer:Timer = new Timer(tempo,1);
    timer.addEventListener(TimerEvent.TIMER, switchToColorZero);
    var boxi:int = -1;
    var boxi2:int = -1;
    function changeColours():void
        //trace("changeColours() :" + getTimer());
        ct.color = colour[2];
             if(boxi < boxes.length - 1)
                boxi += 1;
             else
                boxi = 0;
             //if white turn green
             if(boxes[boxi].ONOFF)
                boxes[boxi].transform.colorTransform = ct;
             else
                mix1Transform = new SoundTransform(currVol,currPan);
                mix1 = kick.play();
                mix1.soundTransform = mix1Transform;
                trace(currVol,currPan);
             if(boxi2 < boxes2.length - 1)
                boxi2 += 1;
             else
                boxi2 = 0;
             if(boxes2[boxi2].ONOFF)
                boxes2[boxi2].transform.colorTransform = ct;
             else
                mix2Transform = new SoundTransform(currVol2,currPan2);
                mix2 = hat.play();
                mix2.soundTransform = mix2Transform;
                trace(currVol2,currPan2);
             timer.start();
    function switchToColorZero(e:TimerEvent):void
        //trace("switchToColorZero() :" + getTimer());
            ct.color = colour[0];
            if(boxes[boxi].ONOFF)
                boxes[boxi].transform.colorTransform = ct;
            if(boxes2[boxi2].ONOFF)
                boxes2[boxi2].transform.colorTransform = ct;
            timer.stop();
            timer.reset();
            changeColours();

    What kind of Timer are you writing about..... specify ....
    I know java.util.Timer()
    example with repeats
    java.util.Timer t = new java.util.Timer();
              t.schedule(new java.util.TimerTask() {
                   public void run() {// do something
              }, delay, period);delay - delay in milliseconds before task is to be executed.
    period - time in milliseconds between successive task executions.
    example without repeats
    java.util.Timer t = new java.util.Timer();
              t.schedule(new java.util.TimerTask() {
                   public void run() {// do something
              }, delay);Good Luck

Maybe you are looking for

  • Excise base amount not upadting in J_1IEXCDTL

    Hi, For some excise document line items Excise base amount is not flowing in J_1IEXCDTL. We are making excise document with reference to Proforma Invoice, in Proforma invoce all the line items are having value and even i checked for these line items

  • Need to install ADR in my weblogic server 10.3.6

    Hi, I have installed my Standalone weblogic server in my laptop. And i tried to deploy one of my EAR file ( Developed using Fusion Web application - ADF). It shows some exception and i finally came to know that in need to install the ADR. (ADF Runtim

  • Parent-Child hierarchy without facts in top-level

    Hello folks, I've got a fact table which looks like: fact_id | costs | some_id 1 | 5 | 1 2 | 10 | 1 and a hierarchy which looks like: id | super_id | some_id 1 | null | null 2 | 1 | 1 3 | 1 | 1 In the business logic layer I defined two keys for the d

  • Dynamic Action in CKE Editor / rich text

    Dear fellow developers, I created some dynamic actions in Apex 4.1.1, which allow me to create function keys in my application. For example on "key-down F10" a modal dialog opens or upon hitting "F11" the user is redirected. While this works as long

  • Inserting Logo in mail forms

    Hi Gurus, I am trying to insert picture in one of the mail form, after inserting and when i click on SAVE, I get a display " Your session has timed out! Click here to restart. ". I have added the picture ( .BMP) file in the SE78 transaction. Please h