Timer works if I set the time before the current one

Hi,
I've got a block that is part of an actionListener that has 4 buttons, anyway I want the timer to execute something exactly at the time I set it.....but in the code that I have it also executes if i set the time before the current time
Here's the segmant:
private class ButtonResponder implements ActionListener
          public void actionPerformed(ActionEvent event) 
                if (event.getSource() == exitButton)
                              System.exit(0);
               if(event.getSource() == setButton)
                    int hour = Integer.parseInt(hours[hourComboBox.getSelectedIndex()]);
                    int min = Integer.parseInt(minutes[minuteComboBox.getSelectedIndex()]);
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.HOUR_OF_DAY, hour);
                    calendar.set(Calendar.MINUTE, min);
                    calendar.set(Calendar.SECOND, 0);
                    Date time = calendar.getTime();
                timer = new java.util.Timer();
                    timer.schedule(new TimerTask()
                         public void run()
                              JOptionPane.showMessageDialog(null, "it is time");
                    , time, 5*1000);
               if (event.getSource() == cancelButton)
                    timer.cancel();
          }So if I put zeros in hours and minutes it will execute immediately....how can I make execute at the exact time (so that if the time now is 2:00 and I set it to 1:00 it only executes the next day??
Message was edited by:
Octavian

Bump the day if the time is less than current time.
Kaj

Similar Messages

  • Purchased a new Apple TV and the remote double clicks each time I press the button. It worked fine during set up and for the first two days.  I have since moved it and this problem started. Restarted,reset,unplugged,change remotes, no change.Help please.

    Purchased a new Apple TV and the remote double clicks each time I press the button. It worked fine during set up and for the first two days.  I have since moved it and this problem started. Restarted,reset,unplugged,changed remotes, no change. Latest software update. This is really annoying.  iPhone remote app works just fine.  Any suggestions?

    That's one of the weird things.. it recognizes it maybe 10% of the time. And usually, only after I do the two-button reset. Problem is.. since it won't charge above 2%, anytime I try to do a restore or anything like that using iTunes, my device shuts off and I lose whatever progress I'd made.
    So, an update... after reading through a bunch of similar complaints (there are literally 1000's of them so there's NO WAY this isn't somehow ios7 related, thanks a lot APPLE ) I decided to try a restore in recovery mode. After 3 hours and several disconnections... I ended up having to just set it up as a new iPad, as the restore did nothing. Weirdly though... as I was doing the restore in recovery mode.. I noticed I'd gotten up to a 10% charge.. higher than it's been since September, so after setting it up as a new device, I turned it off and plugged it in using the wall charger. 2 hours later and I was up to 38%. Still not great, as my iPad, before ios7 could've fully charged twice in the amount of time it took for me to now get 28% more of a charge. And that's with a fully cleaned out device.. so that really ***** and I'm now more confused than ever.
    But I'm gonna leave it overnight charging and see what I come up with tomorrow. Sadly, when I paid $600 for it in February, I never expected to have to play "wait and see" with it...

  • "The end date can't be set to occur before the start date" issue

    I have a subscribed calendar that draws from data in a Filemaker database. In all of these records, the start date & end date are the same. When I try to refresh the description, it fails with a "NSCocoaErrorDomain / error 1560" error, and the console log shows "The end date can't be set to occur before the start date."
    Well, it doesn't occur before the start date. It's the same as the start date. I can work around this by setting my Filemaker database to add a day to the end date, but that's a clunky solution.
    Anyone else run into anything like this?
    (iCal 4.0.3 and OS X 10.6.4, btw)

    It may not be the same problem, but the message was the same (end date...etc). I tore my hair out at the time trying to solve it. It was on my fathers computer. Everything appeared to be correct and consistent. What solved it was logging into MobileMe/account/personal info/time zone, where I found the time zone was wrong. I can't remember the detail now but at the time it seemed like a third place where time had to be correct. Worth your checking there anyway.

  • Does the SCOM 2012 agent "look back" in the logs before the service was started?

    Does the SCOM 2012 agent "look back" in the logs before the service was started?<o:p></o:p>
    We raised this question to our Microsoft rep back when we migrated to SCOM 2007. We wanted to know if SCOM would alert on errors generated before the Heath Service started. For example, errors
    logged before the service is started on reboot (which is when some critical errors are logged). We also wondered what happens when the service is restarted...would errors during the same window be missed?
    If I remember correctly the MS response was that the agent looks back on startup/restart based on a timestamp of some kind. We did some testing that seemed to confirm this information. I've
    recently encountered several instances of errors generated while the service was stopped (primarily during boot up) where SCOM failed to alert on the error.
    Can anyone confirm how the SCOM 2012 agent deals with errors generated before the service starts on boot and during service restarts?

    I would suspect it's with watermarks as it has been in the past.  What you should look into is if these alerts you were expecting are event based, and if there are rules set to alert for these conditions.  If so, and you don't get an alert,
    then you can bring that up with your msft rep.  However, they should be caught.
    Regards, Blake Email: mengotto<at>hotmail.com Blog: http://discussitnow.wordpress.com/ If my response was helpful, please mark it as so, if it answered your question, then please also mark it accordingly. Thank you.
    There is a watermark. If the agent has been down for a significant period of time, the watermark may not apply, as the log would have rolled - but the entire log will still be processed regardless of what has already been discarded in the log. This may cause
    some problems if a monitor picks up an unhealthy state, and the healthy state log entry has already been flushed. In this case, you need to reset health on that particular monitor, or just flush the cache on the agent to start anew.
    Jonathan Almquist | SCOMskills, LLC (http://scomskills.com)

  • I modify a document en word and saved it. I need to return to the document before the modification. How can I do it? Thank You

    I modify a document en word and saved it. I need to return to the document before the modification. How can I do it? Thank You

    Are you using Time Machine? If not, do you have a backup?
    Best of luck.

  • The call was cancelled by the caller before the remote party answered

    Hi,
    We have a Lync 2010 Enterprise deployment in a single site with 2 FE and Mediation Server collocated.
    When dialling a number from a PSTN phone the call gets routed via our PBX/PBX Gateway/Mediation Server/FE Server to the desktop Lync client successfully.
    As soon as the user answers the call with the Lync client the call 'hangs' and terminates without hearing anything on either side.
    The snooper logs show:
    Error:
    SIP/2.0 487 Request Terminated
    Partial Content:
    User-Agent: UCCAPI/4.0.7577.4398 OC/4.0.7577.4398 (Microsoft Lync 2010)
    Ms-client-diagnostics: 52092;reason="The call was cancelled by the caller before the remote party answered"
    Content-Length: 0
    Please help?
    Vinkie

    What kind of gateway are you using to connect to your PBX and how?  What is your media set to?  G.711 μ-law or a-law?  I'd check media settings there as a starting point. 
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".

  • How can i say yes to automatic updates when they stop my wireless dlink to Virgin home broadband from getting on the internet and then i have to do a system restore to the day before the update to get it back to normal?!? Frustrated

    how can i say yes to automatic updates when they stop my wireless dlink to Virgin home broadband from getting on the internet and then i have to do a system restore to the day before the update to get it back to normal?!? Frustrated
    == This happened ==
    Not sure how often
    == automatic updates go on my computer, say if i click yes to update when shutting down

    You have 10.6 on that machine, I suggest you stick with it for performance, third party hardware and software reasons as long as possible.
    Consider 10.8 (not 10.7) when it's released, because 10.7 and 10.8 will require a new investment in software and newer third party hardware as it requires newer drivers the old machines won't have. (forced upgrade because of software, really nice of them)
    http://roaringapps.com/apps:table
    Far as your Safari problem do these things until it's resolved:
    1: Software Update fully under the Apple menu.
    2: Check the status of your plug-ins and update (works for all browsers) also install Firefox and see if your problems continue. You should always have at least two browsers on the machine just in case one fails.
    https://www.mozilla.org/en-US/plugincheck/
    Flash install instructions/problem resolution here if you need it.
    How to install Flash, fix problems
    3: Install Safari again from Apple's web site
    https://www.apple.com/safari/
    4: Run through this list of fixes, stopping with #16 and report back before doing #17
    Step by Step to fix your Mac

  • I was wondering, once the 1gb free data is applied to the account, can you downgrade your plan?  If so, how low can you drop the data before the promo is affected?

    I was wondering, once the 1gb free data is applied to the account, can you downgrade your plan?  If so, how low can you drop the data before the promo is affected?

    I beleive you have to keep your PAID data of at least 1gb

  • The application "Droplr" is open. You must quit the application before the installation can begin.

    The application "Droplr" is open. You must quit the application before the installation can begin.

    Look on your dock. Do you see the icon? If it has a light turned on (underneath the icon), then it is still open. Make sure you quit the app.

  • When I make a audio recording, I miss the breathing before the first note using metronome click

    When I make a audio recording, using count in metronome click, I miss the breathing before the first tone. I hear very abrupt the first tone. I like some environment before, the acoustic of the hall

    So... if i understand what you are trying to achieve...
    When recording sing a single short note (To actually start the recording and then wait a bar before you start actually singing your music.. You can then go back and edit out the single note leaving the ambience... and your breathing intact and recorded.

  • How to indent to the left (before the margin)?

    In Word I could easily put the triangle of the ruler to the left, before the margin.
    Example: when I want to do the following (>>> stands for a tab):
    2p>>>[begin of the margin] Exercise A
    [begin of the margin] Put the following etc etc
    I want to put "2p" before the margin.
    Is it possible to do, and if it is, how?
    Thanks!

    Seems impossible in iWork (even 08)

  • I have been having problems since i installed the quicktime update yesterday. can i revert to the version before the update?

    I have been having problems since i installed the quicktime update yesterday. can i revert to the version before the update? how would i do that?

    Hi, I don't think I've done that for a few years, but what exact version was it you installed?
    Is this an Intel iMac, or a PPC iMac?
    At the Apple Icon at top left>About this Mac.
    Then click on More Info>Hardware and report this upto but not including the Serial#...
    Hardware Overview:
    Model Name: iMac
    Model Identifier: iMac7,1
    Processor Name: Intel Core 2 Duo
    Processor Speed: 2.4 GHz
    Number Of Processors: 1
    Total Number Of Cores: 2
    L2 Cache: 4 MB
    Memory: 6 GB
    Bus Speed: 800 MHz
    Boot ROM Version: IM71.007A.B03
    SMC Version (system): 1.21f4
    Pehaps more important, what exact problems are you having Kim?

  • What is the difference between the new 13" MacBook Pros and the previous version of the 13" MacBook Pro?  I purchased an "old" one from Best Buy the day before the announcement of the new models.

    What is the difference between the new 13" MacBook Pros and the previous version of the 13" MacBook Pro?  I purchased an "old" one from Best Buy the day before the announcement of the new models.

    See the specs:
    Compare Notebooks - Apple Store (U.S.)
    Compare with your model. If you are within 14 days of purchase you can exchange for the new model for the difference in price, if any. Be sure to have all the original packaging and your receipt.

  • Hello to everyone. I get a lock surrounded by an arrow in the part before the battery icon

    hello to everyone. I get a lock surrounded by an arrow in the part before the battery icon, I can not turn the display screen to write or see internet, I would not have to restore the Ipod.Help me please

    Your orientation lock it switched on. To turn off do this: Open the multitask bar by double clicking the home button, swipe from left to right until you see the lock icon next to the play controls. Tap on it to unlock and close the multitask bar again by clicking the home button.

  • I have upgraded my pages in my ipad but i cant read it when i send it to my macpro? do i have to buy the apps for my imac? If i have to can I revert to the old one meaning the pages before the upgrading/

    i have upgraded my pages in my ipad but i cant read it when i send it to my macpro? do i have to buy the apps for my imac? If i have to can I revert to the old one meaning the pages before the upgrading?

    If you have iWork 09, then the latest version should be available for free in the Mac App Store. If you have the new version on your iPad, then you'll need the new version on your Mac as well. The whole point of the latest version is that you can access and edit your files equally on iPad/iPhone, Mac, and also through the iCloud website.

  • How do I unsync, restore my bookmarks, etc. to the state before the sync.

    I need to unsync my bookmarks etc. That is restore to the condition before the sync.

    See: http://support.apple.com/kb/HT4686
    Wordpress is probably the best, most popular blogging software. http://wordpress.org
    To convert iWeb to Wordpress see: http://www.ragesw.com/products/iweb-to-wordpress.html

Maybe you are looking for

  • Can't install iTunes in windows vista x64 (error 0x80070002)

    I have been encountering some trouble when trying to install iTunes in my Windows Vista 64-bit PC. When I attempt to install it, it gaves me a HRESULT: 0x80070002 error. I have been looking on the internet for a solution to this and have already trie

  • Cannot install camera raw 6.3

    I downloaded camer raw 6.3 from the adobe downloads site but I cannot install it. There is no camera raw 6.3 installer.exe. There is an AdobePatchInstaller.exe but it returns an error code "update is not applicable" when I run it. Any suggestions. Ji

  • IWeb '09 and Reflections?

    Ok, in iWeb and adding photos in Blog, when I add a reflection on photo it is always at 100% Transparent but when I go into archives the photo is 50% transparent on the reflection under inspector no matter what I do it still appears at 100%? I have a

  • Best way to create functional pages

    We are getting ready to migrate all our content and functional pieces from out old CMS to CQ5. We have 20 or so pages that are not managed for content. They are basically forms that handle calculations. So we don't really need these in CRX for conten

  • Problems ripping from c

    when i rip from cd's to my zen sleek why do some tracks jump is it because it goes through windows media player because when i play them back throuhg wmp the same thing happens