How do i create a delay before something is painted?

hey, could someone tell me how to create a small delay for 2 seconds. I'm writing this program and when the user clicks on a black panel, the panel will change to show the image for 2 seconds and then turn black again. I know how to display an image and that, but I don't know how to make a delay? at the moment the repaint() method is gettin called too quickly and so the image is probably shown 4 a split second then changed back to black.
The following is just some simpler pseudo code to show my problem.
if(panelClicked) {
    displayImage = true;
    repaint()
//i'd want to put a two second delay here
panelClicked = false;
displayImage = false;
repaint();thanks

saru88 wrote:
well aren't u nice, "RTFM"..... READ THE F$%$ING MANUALWhat's not nice in reading the fine manual?
.I'm new to this whole swing thing and i'm doing my best to get this done before the dealine. I only started learning swing a couple of weeks ago and i do usually read those things but i'm programming it slightly differently and not sure abt the way to use things. Good to see ur a nice guy aye....Then you've got much bigger problems than learning Swing (namely, management, or organization, or self-organization problem). I've been through pressure too, for most of my short carrer, so I sympathize.
But in this case the manual is the spoon-fed javadoc link for javax.swing.Timer, and I'd add the tutorial's [1-page section|http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html]. Skipping these 30mn reads has a low short-term gain, while the ROI (saved hours, possibly days, of debugging) of actually reading them is tremendous.

Similar Messages

  • How do I create a delay or time-lag for my data in LABVIEW

    In my data acquisition system I am using acquired data to create an digital output. I want to delay this output or create a sort of time lag for it. Is there any easy way to incorporate this?

    What you might consider doing is using a sequence. Run the data through this sequence and inside of the sequence, put a delay equal to the time you wish to delay the signal. Then, the output will not be available until the delay has completed.
    If you need continuous streaming data, this might not work too well. Then, you will need some sort of a data buffer - perhaps using a queue might be one possible solution. I have not used it, but I think that queues can have a time stamp. You could possibly artifically alter the time stamp.
    Hope this helps,
    Jason

  • HT2731 How do I create a password before i purchase songs or books?

    When I purchase songs or books it automatically charges my acct.  I would like to use my password first.  How do I set that up?

    if (textbox1 password = textbox2 password)
    update the row in the database
    else
    display = "textbox2 does not match textbox1" "try again"
    Again you could use javascript validation techniques, regular
    expressions etc.

  • How to create delay before tween or function in AS?

    Hi there
    I have a number of cases where I have a tween happening in ActionScript, but I would like it to happen after a delay from the event that triggers it. At the moment I'm creating this delay by having a tween that does nothing (eg. an "_x" tween for which the start and end points are the same) and then using tween1.onMotionFinished = function(){… to create the one I really want.
    Is there a way to create this delay more neatly? At the moment what I am doing works fine, but it's still a workaround and if there's a better way to do it I'd like to learn. It'll probably help me out in the long term.
    I'm using AS2 in CS3.
    Thanks!

    Try using setInterval

  • How do I create more room on my MacBook Pro so I can install Snow Leopard?  It says it needs 5GB and I have 4.something.

    How do I create more room on my MacBook Pro so I can install Snow Leopard?
    I've only got 4.something GB left and it says it needs 5 GB? 
    Which then begs the question, will I be able to do anything with the computer.
    I think I need to get some stuff off, but do not know where to look up what is taking up the most room.
    I have an extra hard drive.
    I have iDisk.
    I have a Time Machine, but it backs up one of my three Macs.
    Thanks.

    A utility like GrandPerspective is a good one for seeing what is taking up space on your hard drive.
    Video and photo files tend to take up a lot of room.

  • How do I create a variable video delay of a live stream...

    I have a live video feed from my webcam in my Flash Application. I have a second video window next to it that I want to place a variable delayed video of the live stream. Therefore, I need to save the video stream in memory/disk and create this variable delay, say 5-60 seconds. As well as, continue to capture the live stream. The camera I am using suppots H.264 encoding.
    How do I create a variable length queue or buffer to hold the video stream coming into the flash application. Do I create a memory variable or write this to disk ? I have been looking over the ActionScript 3.0 documentation and I can not figure out how to code this either way ( as a memory variable or write to disk queue ).
    I want to be able to change the delay, view the delay stream in slow motion and scrub through the delayed stream.
    I would like to do this with out having to use Flash Media Server.
    Thanks,
    Bob

    I am sure it is practically impossible to accomplish that on the client side. Although theoretically it is conceivable to use NetStream.appendBytes() but it requires an extremely complex implementation.
    I suggest you look into FMS DVR capacities:
    http://help.adobe.com/en_US/flashmediaserver/devguide/WS236AE81A-5319-4327-9E44-310A93CA09 C6Dev.html

  • How to change number of retries and delay before retrying after software install failure

    I deploy a software to client, but the installation is fail, so it will retry. but How to change the number of retries and delay before retrying after software install failure?
    I find "Retry Settings" in "Software Distribution Component Properties". But I think it work for Distribution, not the installation. am I right?

    First, are you referring to packages or applications because the behavior is different.
    Also, why do you want it to retry a failure? It failed for a reason so you need to fix the cause of the failure first. If it failed the first, it will likely fail the next time for the same reason. In general, ConfigMgr will only retry on transient type
    errors.
    Jason | http://blog.configmgrftw.com

  • HI, I need your help. How can I delete all data, when I do not have the special security code, which I didn´t remember ? I also think, that I never create this code before. But I cannot put my settings back.

    HI, I need your help. How can I delete all data, when I do not have the special security code, which I didn´t remember ? I also think, that I never create this code before. But I cannot put my settings back.

    You must remember the code, if you can't then take the phone and proof of purchase to an Apple Store.

  • When creating a fillable form and saving it as a pdf, the default color of the data fields is a light blue. How do I change the color to something else that will copy better, e.g. a light yellow?

    When creating a fillable form and saving it as a pdf, the default color of the data fields is a light blue. How do I change the color to something else that will copy better, e.g. a light yellow?

    It's probably the fields highlight color of the application, which you can change via Edit - Preferences - Forms.

  • Hi there, I want to know how I can set a password before I can purchase anything so I don't accidentally purchase something. Any suggestions?

    Hi there, I want to know how I can set a password before I can purchase anything so I don't accidentally purchase something. Any suggestions? Thanks

    Settings > iTunes & App Stores > Apple ID ...
    Sign in, and, if you like, change your password there by clicking your Apple ID again after signin.

  • On a flash game how do you create something to let you switch vehicle

    I know how i can create a button but how do i make it activate different vehicles before the race starts.

    A bit of advice, You should not be making a racing game as its very clear that you are new to actionscript. In my eye's a racing game is by far the hardest type of game to make.
    But to create a button, you draw it, convert it to symbol. Makie it a movieclip Look in the properties panel where it says instance name, give it a instance.
    The where ever that button is in your file, place the code in the actions panel on the same location of the button.
    You should not ever copy and paste code unless you understand it, you WILL get many errors if you keep doing this as you do not understand the process. If someone offers you code, you should manually type it in. If you type it inyourself, your brain is more focussed on the code, meaning you get used to it easier.
    But as for your simple tutorial,
    1. Draw your button.
    2. Right click, then 'Convert to symbol'
    3. Make it of the Movieclip type.
    4. Go to your properties panel. Give it a instance name, in this case "btnins"
    4. On that same scene, go to your actions panel, and TYPE in:
    btnins.addEventListener(MouseEvent.CLICK,btnfn);
    function btnfn(e:MouseEvent):void{
         mc.gotoAndStop(Math.floor(Math.random() * (1+10-1)) + 1);
    And yes you would need the 10 keyframes within your Car movieclip. But you WILL get even more confused in a minuite as im sure this will not achieve your goal. If i understand, you are looking for a select car, before the game starts, correct ?

  • How do I create Themes/Chapters in my video before burning to DVD so that Scenes can be selected when DVD is loaded to player?

    How do I create Themes/Chapters in my video before burning to DVD so that Scenes can be selected using on screen icons when DVD is loaded to player?

    "I don't know what you mean by this. There are no chapter markers in FCP." - you puzzle me by this! Yave You ever made some DVDees after editing in FCP 7? Every chapter in the timeline could be transfered to DVD Studio Pro, and then used in DVD navigation. This is very important feature, decause you don't have to lookfor some parts of your video while creating navigation! Less work - more joy! Another downscore of FCPX!

  • How can I create back up from ipad 2 before opting for restore setting

    how can I create back up in my computer from ipad2 before opting for restore setting, as I have forget my password for ipad and it has been diabled and not at all open by making several attempt

    Recovery Mode:
    1. Turn off iPad
    2. Connect USB cable to computer; leave the other end alone
    3. Press and hold the Home button down and connect the docking end of cable to iPad
    4. Continue holding the Home button until you see the "Connect To iTune" screen
    5. Release the Home button
    6. Open iTune
    7. You should see "iTunes has detected an iPad in recovery mode"
    8. Use iTune to restore iPad
    Note: You need to be patient and repeat the above many times to recover your iPad

  • How do I create a beta site for my client to preview before publishing?

    how do I create a beta site for my client to preview before publishing?

    Provide the name of the program you are using so a Moderator may move this message to the correct program forum
    This Cloud forum is not about help with program problems... a program would be Photoshop or Lighroom or Muse or ???

  • HT203177 I have not backed up my computer using Time Machine since before I updated to Mavericks.  It has been "preparing backup" for a half hour at least and shows no indication of how long this may take.  Is something wrong?

    I have not backed up my computer using Time Machine since before I updated to Mavericks.  It has been "preparing backup" for a half hour at least and shows no indication of how long this may take.  Is something wrong?

    No. TM has to look through your entire drive contents and copy them all. This will take some time.
    Once the first backup is made, then subsequent backup will be much quicker, depending on how much data has changed since the last one.

Maybe you are looking for

  • Can't see new new message window

    When trying to send mail, when I attempt to open a new message window, it will not display. If I look under the window tab in the task bar, I can see that a new message window has been opened, but even if I highlight the new message, it will not disp

  • F5080 error: Consolidated Companies & and & are different - HR

    Hi Experts We are trying to post the payroll and error F5080 comes up.  It refers to Trading partner and / or Intercompany posting which I have set  in the document type.  I have searched the net and OSS, but can't find a solution for HR. Can anyone

  • Cover Flow - visual issues

    I decided to rearrange my Bookmarks today and didn't even know Safari 4 had all these clever new additions! Cover Flow in Safari??? I use iTunes all the time as a visual guide and to have it here was a great idea. My niggling problem is that around 9

  • Language Support: Custom Build/Debug actions

    Hi! I'm trying to develop a custom language service, but can't find a way how to register custom build action instead of default C# compiler. I followed this two (Language Service, Basic Project System) walkthroughs, but unfortunately couldn't find a

  • Video not working when online - HELP!

    I am putting video into flash, to go online and am pretty new to it. I followed a couple of discussions in here to the letter, but it doesnt see to work once i upload it all. I did this: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?fo