How can I wait until a Swing.Timer has finished?

I have a Swing.Timer runing which displays some animated text (more precisely it fades out a text with a delay of 50 until all characters are erased.
Afterwards a time consuming operation shall begin. How can I achieve that this operation waits to start until the text has been faded out? The time to fade out the text depends on the length of the text, of course.
So, how can I make the operation waiting until the Timer has finished its work?
Thanks,
Dirk

dirku wrote:
I have a Swing.Timer runing which displays some animated text (more precisely it fades out a text with a delay of 50 until all characters are erased.
Afterwards a time consuming operation shall begin. How can I achieve that this operation waits to start until the text has been faded out? The time to fade out the text depends on the length of the text, of course.
So, how can I make the operation waiting until the Timer has finished its work?I gave you an answer to this with sample code yesterday:
[http://forum.java.sun.com/thread.jspa?threadID=5294087&messageID=10244564#10244564|http://forum.java.sun.com/thread.jspa?threadID=5294087&messageID=10244564#10244564]
        public void actionPerformed(ActionEvent e)
            if (sb.length() > 0)
                sb.deleteCharAt(0);
                label.setText(sb.toString());
            else
                label.setForeground(color);
                label.setText(text);
                Timer timer = (Timer)e.getSource();
                timer.stop();
                // ***** start process here ***
        }The timer here continues until a condition is satisfied (here it's where the Stringbuffer that holds the text that is sent to the JLabel is empty). So all you have to do is place any code that needs to happen when the Timer ends in the else block. It's so simple as to be trivial.

Similar Messages

  • Waiting on a Swing Timer To Finish

    This is my first post so if I've done something wrong I am very sorry. I am Trying to move a sprite across the screen when the user pushes a JButton. To accomplish this I am using a swing timer the problem is I need to execute some method after the animation is finished, but since both the animation and the other code run on the EDT the code I place after the animation executes first. I've tried using threads, but that did not help. I have included an example below, thanks in advance.
    // called by the JButton's ActionListener
    public void actionPerformed(ActionEvent e)
         methodToBeCalledBeforeAnimation();
         animateSprite(x_start, y_start, x_end, y_end, mySprite);
         methodToBeCalledAfterAnimation();
    public void animateSprite(x_start, y_start, x_end, y_end, Sprite sprite)
         int delay= 10;
         if (getTimer()!= null) return;
              class Animator implements ActionListener
                   int maxFrames= 50;
                   int frames= 0;
                   int x_start;
                   int y_start;
                   int x_end;
                   int y_end;
                   int width;
                   int height;
                      Sprite sprite
                   double x_curr;
                   double y_curr;
                   public Animator(int x_start, int y_start, int x_end, int y_end, int width,
                                      int height, Sprite sprite)
                        this.x_start= x_start;
                        this.y_start= y_start;
                        this.x_end= x_end;
                        this.y_end= y_end;
                        this.width= width;
                        this.height= height;
                        this.sprite= sprite;
                        sprite.setHeight(height);
                        sprite.setWidth(width);
                        x_curr= x_start;
                        y_curr= y_start;
                   public void actionPerformed(ActionEvent evt)
                        x_curr= (double)sprite.getX()+(double)x_end/(double)maxFrames;
                        y_curr= (double)sprite.getY()+(double)y_end/(double)maxFrames;
                        sprite.setX((int)x_curr);
                        sprite.setY((int)y_curr);
                                    // sprite is drawn in paintComponent
                        repaint();
                        frames++;
                        if (frames==maxFrames)
                             getTimer().stop();
                             setTimer(null);
                             repaint();
              setTimer(new Timer(delay, new Animator(x_start, y_start, x_end, y_end, width,
                                                height, card)));
              getTimer().start();
              return;
    }Edited by: Pherpq on Jul 18, 2008 5:53 PM

    Hi,
    try to change the method from
    // FROM:
         public void actionPerformed(ActionEvent e)
              methodToBeCalledBeforeAnimation();
                        animateSprite(x_start, y_start, x_end, y_end, mySprite);
                        methodToBeCalledAfterAnimation();
    // TO:
      //      called by the JButton's ActionListener
         public void actionPerformed(ActionEvent e)
              methodToBeCalledBeforeAnimation();
              animateSprite(x_start, y_start, x_end, y_end, mySprite);
                           TimerQueue is a thread so wait for this thread to die before you
                          continue
              if(getTimer()!= null) {
                   getTimer().timerQueue().join();
              methodToBeCalledAfterAnimation();
         }I will not comment on the design approach for the method animateSprite(x_start, y_start, x_end, y_end, mySprite); since this is out of scope for this post.
    I hope this could help.
    Regards,
    Alan Mehio
    London, UK
    Edited by: alan_mehio on 21-Jul-2008 11:34

  • I have bought a time capsule to use as time machine device. Until now I have used a external hard disk. How can I transfer the the old time machine datas to the time capsule?

    I have bought a time capsule to use as time machine device. Until now I have used a external hard disk. How can I transfer the the old time machine datas to the time capsule?

    This is really difficult to the point of not really worth it.
    Keep the old TM backups in archive.. and start afresh on the TC.
    Time Machine has a different way of backing up on Network drives cf Local drives.
    Pondini does have a method to do it... but I would not recommend it.
    http://pondini.org/TM/18.html

  • How can I increase the number of times I am notified that I have  a text or voicemail .

    How can I increase the number of times I am notified that I have text or voicemail waiting to be read?.

    DPickRN,
    Making sure you don't miss any messages is very important and we would be happy to go over your options today. Are you using the Visual voicemail or do you call *86 to access your voicemails?
    CandiceH_VZW
    Follow us on Twitter @VZWSupport
    If my response answered your question please click the �Correct Answer� button under my response. This ensures others can benefit from our conversation. Thanks in advance for your help with this!!

  • HT204400 my apple tv show "apple TV can't sign in to the itunes store until the network time has benn set."

    my apple tv show "apple TV can't sign in to the itunes store until the network time has benn set."... what is the network time ? how i resolve this?

    Ronaldo, I'm also in Brazil... It seems to be a problem with us... I've been searching the internet and many people have the same problem.
    I also have a thread open here... If you find a solution, please answer it here so that we can share.

  • How can I clean up queue one-time on Sun Java system messaging 6.3

    Hi,
    <address>Our Email server have a problem, When I run _./imsimta qm directory tcp_local_, There are about 5 Millions of messages in the queue.</address>
    Now our Email server send messages very slowly, how can I clean up queue one-time?
    the command _./imsimta qclean_ is very slowly.
    What can I do to prevent this problem?
    our Email server version is :
    Sun Java(tm) System Messaging Server 6.3-6.03 (built Mar 14 2008; 32bit)
    libimta.so 6.3-6.03 (built 17:12:37, Mar 14 2008; 32bit)
    SunOS email-1 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-V890
    Thank you !

    If you have more than 100,000 messages in the queue, then look at the MAX_MESSAGES parameter in [the job_controller.cnf file|http://wikis.sun.com/display/CommSuite/Job+Controller+Configuration+File]. If the parameter is not specified, it defaults to 100000. If you have more than that number of messages in the channel queues, it will take a long time for new/legitimate messages to be sent because job_controller is only considering the first 100,000 messages in the queue.
    If you get into the "imsimta qm" command do do "sum -database", it will show a summary of what job_controller has in its internal cache and therefore what job_controller is working on. If you compare that to "sum -directory" you will probably see a difference.
    If these are all legitimate messages, you need to increase MAX_MESSAGES, cnbuild, and restart job_controller.
    If they are not, then preventing this in the future will require determining how they got into your queue and correcting that.
    As for removing them, the "imsimta qm" commands allow you to select messages by various criteria and then you can "return" or "delete" them. But yes, that will take a long time if there are many messages because it is a single threaded process and it needs to open and examine each message. You may be able to accomplish the task more quickly with a shell script that works on individual channel queue subdirectories and then run multiple copies of that script in parallel. After you have cleaned out the queue, restart job_controller.
    Also, you might want to consider [the subdirs channel keyword|http://msg.wikidoc.info/index.php/Subdirs_and_nosubdirs_Channel_Options].

  • How can i browse data in my time capsule with my iPhone?

    how can i browse data in my time capsule with my iPhone?

    You might want to take a look at FileBrowser.
    App Store - FileBrowser - Access files on remote computers

  • How can i use in the same time input line and mic to recorder in several track whit SONAR

    I have beem recording only input line because SONAR 4 not recognized the mic in, Help me!!!.
    Thank you. Sorry for my english

    LIMACAR wrote:
    How can i use in the same time input line and mic to recorder in several track whit SONAR 4. I have beem recording only input line because SONAR 4 not recognized the mic in, Help me!!!.
    Thank you. Sorry for my english
    Depending on which soundcard you have there, but if your card is capable for
    ASIO -> activate I/O drivers on Sonar/Options/Audio/Drivers -tab (mic/line sources should be listed there --> activate) and select the mic or/and Line sources on tracks "I" - dialog
    WDM/KS -> use the Surround Mixer or windows recording controls for recording source selection (mic should be listed there)
    MME32 - > same w/ WDM/KS
    If you use Asio4All --> same w/ WDM/KS & MME32
    No mic and line source simultaenously w/ WDM/KS and MME32.
    You perhaps be able to do this w/ kX drivers.
    jutapa
    ADDED:
    You can also install modded version of Audigy 2 drivers/software but I have never done this w/ Li've! 5. so I can't be sure if you get ASIO support for your card.
    Here are the instruction --> http://www.tech-pc.co.uk/audigy-2.php
    jutapaMessage Edited by jutapa on 05-25-2006 02:48 PM

  • How can I see my files on Time Capsul

    How can I see my files on Time Capsul

    Do you mean Time Machine files or ordinary files.. ??
    Did you copy files to the TC? It should just open in the finder as long as the TC is available and the airport utility shows it connected.
    If you want to see the contents of the TM files.. open the sparsebundle and use main Time Machine icon in the dock.
    Read more.. pondini will help you.
    http://pondini.org/TM/FAQ.html
    Try Q15

  • My 2 TB Time Capsule's memory is full because it will not automatically delete old files as it is supposed to, so it is giving me zero backup of my two computers now.  How can this be fixed so my Time Capsule deletes the old data and saves the new?

    My 2 TB Time Capsule’s memory is full because it will notautomatically delete old files as it is supposed to, so it is giving me zerobackup of my two computers now. How can this be fixed so my Time Capsule deletes the old data and savesthe new?
    Neither my local computer consultant nor I have been ableto change any of the settings in Time Machine to correct this problem.  Working with the choices in the TimeMachine, there does not appear that there is any way to change the frequency ofthe backups either, so, after a year has elapsed, the time capsule is full, andmy only choice appears to be to erase all the current data on the Time Capsuleand start over, something that I do not want to at all let alone repeat on anannual basis.  My questions are:
    What can be done to have my Time Capsule delete old filesas it is supposed to do, so it has memory available to allow my computers toback up? 
    Is this a software problem that can be fixed online or isdoes this require a mechanical fix of defective hardware?

    How much data is being backed-up from each Mac?  (see what's shown for Estimated size of full backup under the exclusions box in Time Machine Prefs > Options).
    Is there any other data on your Time Capsule, besides the backups?
    Most likely, there just isn't room.  Time Machine may be trying to do a very large (or full) backup of one or both Macs, and can't.  Since it won't ever delete the most recent backup, there has to be enough room for one full backup plus whatever it's trying to back up now, plus 20% (for workspace).
    Also see #C4 in Time Machine - Troubleshooting for more details.

  • How can i know if the face time is working on the iPad before i buy it?

    How can i know if the face time is working on the iPad before i buy it?

    I am plan to buy new ipad2 and i want to check before i buy it, if there is facetime or not?
    As far as i know if it is from KSA there is no face time in, but if it from US there is facetime in?
    And i have the serial number.

  • How can I print the date and time in a photo from iPhoto

    How can I print the date and time in a photo from iPhoto

    You want to print them on their own? Can't be done. WIth the photo? Install this
    http://www.iborderfx.com/iborderfx/

  • How can i find out the last time a back up to icloud was done

    How can i find out the last time a back up was done to icloud?

    Go to Settings>iCloud>Storage & Backup.  It will be shown just below the Back Up Now button at the bottom.

  • How can I copy the date and time in Mail header?

    How can I copy the date and time in Mail header?
    I can copy everything else in the header for pasting in another application. 
    But not the date and time which is absolutely vital.
    It was ok in 10.6 

    I suppose you could copy it from the Raw Source. View>Message>Raw Source

  • How can I increase the number of times my 4s rings before it goes 2 msg bank?

    My iphone 4s only rings 3 times before it goes to msg bank. How Can I increase the number of times it rings?

    This is controlled by your carrier, so contact them,

Maybe you are looking for

  • Error While connecting a DL585 server using Emulex LightPulse (A8002A) to a 3par Storage Array

    When connecting this Windows 2003 server to the HP 3PAR Array, the customer receive warnings (6-7 per second), for example: ================================== Device (4,3,14) is reserved by other host. DsmSendTURSynchronous: Device(4,3,12), NTStatus(

  • How can I get a CD Rom to open on my Mac?

    I have a CD Rom on which is sign language lessons, but everytime I put it in my Mac it will open so that I can see the various files on the disc, but when I click install it opens a new window and it says "requires Microsoft Windows to install this p

  • Web ADI - Error in BneMailMerge()

    Hi, I have configured a Web ADI letter for Contract Printing and I get an error in BneMailMerge() as the view attached with Integrator doesnot fetch any row. But when I execute the same view from Pl/sql developer,it fetches the rows properly. Any hin

  • Date comparison in WHERE clause

    I have this simple SQL sequence: CREATE TABLE t1 (d1 DATE); INSERT INTO t1 VALUES(CURRENT_DATE); SELECT * FROM t1 WHERE d1 = CURRENT_DATE; It is obvious what it does, yet on Oracle 10g R1 the SELECT query does not return anything. Any ideas on why th

  • Save Converted Document from Previous Version without Confirmation in CC2014?

    Hi Everyone, Is there a way to save a converted document from a previous version of InDesign with the same name WITHOUT the save confirmation dialog box? By a converted document, I mean that when you open a version from CS6 for example the document t