How to make a method sleep without affecting the responsiveness of the GUI

Hi,
I want to make a method sleep for a few second before executing the rest of its body. Apparently Thread.sleep(10000) doesn't do the job as it makes the GUI non-responsive.
Any advice would be deeply appreciated.
Thomas

Here's an example:
package tjacobs.ui.ex;
import java.awt.Color;
import javax.swing.Icon;
import javax.swing.JLabel;
import tjacobs.ui.util.WindowUtilities;
* @author tjacobs
public class Blink extends JLabel implements Runnable {
     public static final long DEFAULT_TIME_LENGTH = 1000;
     private long mTimeLength = DEFAULT_TIME_LENGTH;
     private String mLabel;
     private Icon mIcon;a
     public void run() {
          mLabel = getText();
          mIcon = getIcon();
          try {               
               while (true) {
                    Thread.sleep(mTimeLength);
                    String current = getText();
                    if (current.equals(mLabel)) {
                         setText("");
                         setIcon(null);
                    else {
                         setText(mLabel);
                         setIcon(mIcon);
                    repaint();
          catch (InterruptedException ex) {
               ex.printStackTrace();
          finally {
               setText(mLabel);
               setIcon(mIcon);
     public Blink() {
     public Blink(String arg0) {
          super(arg0);
     public Blink(Icon arg0) {
          super(arg0);
     public Blink(String arg0, int arg1) {
          super(arg0, arg1);
     public Blink(Icon arg0, int arg1) {
          super(arg0, arg1);
     public Blink(String arg0, Icon arg1, int arg2) {
          super(arg0, arg1, arg2);
     public void setBlinkTime(long time) {
          mTimeLength = time;
     public long getBlinkTime() {
          return mTimeLength;
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          Blink b = new Blink("Hello World");
          b.setBackground(Color.RED);
          WindowUtilities.visualize(b);
          b.setFont(b.getFont().deriveFont(24.0f));
          b.run();
}

Similar Messages

  • How to make changes through JAG without affecting manual changes in jspx?

    hi,
    In our Application , we are using JHeadStart for creating JSPX pages. We made manual changes to some component in Jspx page. Now I has to change TextBox Component to LOV (List Of values) Component. So I made changes in the ApplicationDefinition. xml file. Now If I run the ApplicationDefinition File, the Manual changes (adding setActionListener,creating ManagedBean, etc...) whatever I had made to the particular page is updated to its own default page based on ApplicationDefinition.xml.
    So , is there any possibility that manual changes made to jspx file should not be affected even if we make changes through ApplicationDefinition.xml file.
    Thanks,

    You should write your customizations in generator templates before you JAG. You can add your customizations to affect various components, beans, etc. You then configure these templates to be used by JAG. Once you do this you do not need to re-write your customized code. You will need to know the basics of VTL (velocity template language) as all the templates used by JAG are written in .vm files that use VTL.
    For a more detailed understanding of how using and implementing customized templates read Oracle JHeadstart 10g for ADF Developers Guide, chapter 4.7
    Regards,
    Amit

  • How to format my computer without affecting the software installed?

    how do I format my computer without affecting the software installed?

    You can, but if you don't format the drive using the Zero Data option all your personal files will still be accessible to someone who knows how to gain access to them. If that's not a concern then here are two options (easy and not so easy):
    The Easy Way
    1. First, boot from your Tiger DVD, select your language and click on the Continue button, then select Disk Utility from the Utilities menu, select your boot hard drive, go to the First Aid tab, and click the button for Repair Disk. Repeat this until no trouble is found. Then click on the Repair Permissions button. Then quit DU, return to the installer and shutdown the computer for a couple of minutes.
    This will assure that the drive is OK and permissions are OK.
    2. Next, boot to single user mode by restarting and after the chime press and hold down the COMMAND-S keys until a black screen with white type appears.
    3. At the prompt, type the following commands pressing return after each command line:
    /sbin/fsck -yf
    mount -uw /
    rm /private/var/db/.AppleSetupDone
    shutdown -r now
    The second-to-last command above will cause OS X to think that the operating system is newly installed, and when you reboot, it will send you to the startup wizard where you can start a new user without reinstalling.
    The Not So Easy Way
    Follow these instructions step by step to prepare a Mac for sale:
    First, back up the data:
    1) Shut down all Virtual PCs. They cannot be in their "fast saved" state. They must be shut down from inside Windows.
    2) Clone to an external drive using Carbon Copy Cloner.
    Next, prepare the machine for the new buyer:
    3) Deauthorize the computer in iTunes! Deauthorize both iTunes and Audible accounts.
    4) Remove Open Firmware passwords
    5) Turn the brightness full up and volume nearly so.
    Install a fresh OS:
    6) Insert the OS X install CD/DVD.
    7) Restart the computer while holding down the C key to boot from the CD/DVD.
    8) Run Disk Utility from the file menu and erase the internal hard drive (optionally zero all data).
    9) Install OS X.
    10) Reboot the computer.
    11) From the welcome screen, you can skip the registration step by typing command-Q.
    12) When prompted, create an account (it will be an admin account).
    13) From your new admin account, configure networking.
    14) Then use Software Update to bring your system and all of it's applications up to date.
    15) From Disk Utility, repair permissions on the new volume.
    Now delete the account you just created:
    16) Boot from a different volume (e.g. a firewire drive, if available)
    17) Clean up the image using the following terminal commands:
    prompt> rm /Volumes/<imagevol>/var/db/BootCache.playlist
    prompt> rm /Volumes/<imagevol>/var/db/volinfo.database
    prompt> rm -r /Volumes/<imagevol>/var/vm/swap*
    18) Now you can get rid of the admin account you used to set up the machine Use the terminal:
    prompt> nicl -raw /Volumes/<imagevol>/var/db/netinfo/local.nidb -delete /users/<admin>
    prompt> rm -r /Volumes/<imagevol>/Users/<admin>
    prompt> rm /Volumes/<imagevol>/var/db/.AppleSetupDone
    19) Shut down and ship it to your buyer. When they get it, it will boot to the Welcome screen just like a factory Mac, except that it's better because it's completely up to date.

  • My MacBook Pro died, but have a TimeMachine backup. I've bought a new one. How do I make the new one just like the old without affecting the OS on the new one?

    My MacBook Pro died, but have a TimeMachine backup. I've bought a new one. How do I make the new one just like the old without affecting the OS on the new one?

    ppauley wrote:
    My MacBook Pro died, but have a TimeMachine backup. I've bought a new one. How do I make the new one just like the old without affecting the OS on the new one?
    One you start up the new one for the first time, Setup Assistant starts and offers you the option of migrating your old Mac to your new Mac with Time Machine, among other choices, as the source. You can also use Migration Assistant (in the Utilities Folder) to do the same thing.

  • How to remove a photo from a LRPublishedCollection without affecting the Publish Service?

    Hello guys!
    I would like to know if there is a way to remove a photo from a LRPublishedCollection without affecting the Publish Service. Basically I would like it to be removed from the collection but I don't want to be added to "Deleted Photos to Remove".
    Thanks a lot!
    Jordy.

    I don't know how to keep it from being put on the "Deleted Photos to Remove" list at least briefly, but if you do this, it'll amount to the same thing:
    * save status for all photos in collection
    * set status of all photos to "do not publish"
    * remove photo from collection.
    * publish the collection, and make sure you call the deleted callback, but don't do anything else.
    * restore previous photo statuses.
    Only works in Lr4+.
    Rob

  • How to replace a layer which has a mask applied without affecting the mask?

    I have a layer with a photo.  I have animated a mask on this layer, but now the client wants the photo replaced with another one.  When I add a new photo to a new layer and copy the mask properties from the good working layer, the mask winds up in a different place than the original.  I've tried doing a replace footage with the source photo trying to make it the new photo but same results, the mask always gets repositioned.
    How can I replace an image on a layer that has an animated mask on it with another one without affecting the mask?
    Thanks,
    Steve

    Thanks everyone.  Now that I understand more about Track Mattes it works fine.  I can scale and position new layers under the animated mask.  This helps tremendously

  • How to enable an axis without affecting the others ?

    I use an 7340 4 axis card with MID7654 driver unit. I have to make several independant programs, using each 1 or 2 of the 4 available axis on the card. I wonder how to enable/disable a single axis without affecting the other, because the "enable axis" VI is not three states : an axis can only be enabled or disabled, but not "not affected". I didn't find any NIMotion VI to do it or to give "all axis" information.
    Any idea ?

    Hi,
        It is possible to check the states of the axis with the function "Read per axis status".
        It is possible to eanable and disable axis with the function "Enable axis".
        Hope it can help.
    .NIDays2008 {font-family:Arial, Helvetica, sans-serif; font-size:12px; color: #065fa3; font-weight: bold; text-decoration: none; text-align: right;} .NIDays2008 a, a:hover {text-decoration: none;} .NIDays2008 a img {height: 0; width: 0; border-width: 0;} .NIDays2008 a:hover img {position: absolute; height: 90px; width: 728px; margin-left: -728px; margin-top:-12px;}
    >> Avez-vous entendu parler de NI Days ?

  • HT201363 My iPhone, iPad and iPod are all associated with the same Apple ID.  How can I remove the iPod and associate it with a new Apple ID without affecting the data on the other devices (note: there is no data on the iPod I want to keep)?

    My iPhone, iPad and iPod are all associated with the same Apple ID.  How can I remove the iPod and associate it with a new Apple ID without affecting the data on the other devices (note: there is no data on the iPod I want to keep)?

    Very simple.  Turn off Find my iDevice, then  Tap Settings, General, Erase, Erase all content and settings.

  • I have 2 ipod touches. I backed up the new one with old's info. The old one will not unlock with the password I had wrote down and I tried my new ones password.  How can I reset the old ipod without affecting the new one and how can I unlock the old one?

    I have 2 ipod touches. I backed up the new one with old's info. The old one will not unlock with the password I had wrote down and I tried my new ones password.  How can I reset the old ipod without affecting the new one and how can I unlock the old one?

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software

  • How do I reformat hard drive without affecting recovery partition?

    I would like to know how I can reformat my Toshiba hard drive without affecting the hidden recovery partition? I would like to get rid of the preinstalled Windows 7 OS and replace it with Windows XP, which is not as bloated. Also, does anyone know of a good 'free' disk scrubber program? I actually have the original 'disk scrubber' software, but the software disk just won't work any more. Finally, I tried to get the computer ready for the drive scrubbing, but I still can't change the disk order on my Toshiba laptop. I did get into the 'bios' screen by hitting the F8 key on startup, which did bring up the 'boot menu' screen. When I selected the cd/dvd drive and then hit the F10 key to save the change, nothing happened! I put in a data disk, but the laptop still booted into the Windows 7 OS. If I can't get the laptop to boot into the cd/dvd drive, I don't think that I can erase the hard drive and put Windows XP on since I wouldn't be able to boot up the laptop with the Windwos XP disk. Is that true? Anyway, without changing the boot order, I can't do anything. Please help! Thanks!

    If you use the recovery that is on the hidden partition (hold down the zero key while starting up computer) then your OS reinstall will not affect that hidden partition, just overwrite the c: drive. 
    L305-S5955, T9300 Intel Core 2 Duo, 4GB RAM, 60GB SSD, Win 7 Ultimate 64-bit

  • How to Hide rows in ALV without affecting total sum at the end of table?

    Hi,
    I need some help in hiding particular rows in an ALV Grid without affecting the total sum at the end of the table. I am trying to hide the rows that have negative quantities, but I still need those values so that the user can still compute for the total sums. Can anyone help? Thanks.
    Joseph

    Hi,
    Hopw this way you can hide the rows in the GRID.
    DATA:
      ld_column      TYPE lvc_fname,
      ld_hide          TYPE abap_bool.
    FIELD-SYMBOLS:
      <ls_entry>     TYPE any,
      <ld_fld>         TYPE any.
      ld_column = 'COL_1'.  " column which you want to suppress if everything is zero
      ld_hide     = abap_true.  " = 'X';  default hide column
      LOOP at <gt_outtab> ASSIGNING <ls_entry>.
        ASSIGN COMPONENT (ld_column) OF STRUCTURE <ls_entry> TO <ld_fld>.
        IF ( <ld_fld>   > 0 ).
          ld_hide = abap_false.  " display column because at least single value > 0
          EXIT.  " leave LOOP
        ENDIF.
      ENDLOOP.
      READ TABLE gt_fcat INTO ls_fcat
                           WITH KEY fieldname = ld_column.
      IF ( syst-subrc = 0 ).
        ls_fcat-no_out = ld_hide.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
    hop you will get the total with for those columns too.
    Regards,
    Madhavi

  • I mounted my external hard drive to a pc and now I don't have edit or write permissions on my Mac (read only). How do I get them back without erasing the drive?

    Hello all, I am a photographer and have my portfolio, edited and raw images backed up on a Seagate Free Agent External Hardrive. I mounted my external hard drive to a pc recently and now I don't have edit or write permissions to it on my Mac (read only). How do I get them back without erasing the drive and loosing my valuable work?

    If you re-format it you will lose all the data on it!!!!! So make sure you have backed up the drive or moved all the data on it to another external HD or the internal HD on your iMac.
    Below is an Apple Advice letter that explains how to format an external HD, it's written for Aperture but you can use the instructions to formate any external HD.
    http://support.apple.com/kb/HT3509

  • Creation of credit notes without affecting the stock on FI side.

    Hello,
    We would like to know about the procedure to follow to create credit notes without affecting the stock.
    For instance a credit note has to be made because the invoice pricing was not correct (discount not taken into account,etc...). We want to issue a credit note for the customer in value (not in quantity) refering to this invoice.
    How to process? Is it supposed to be through a FI transaction?
    Thanks and Regards,
    Rajesh Kumar Mantri

    Dear,
    Use transction FB70 and select Credit Memo in transaction and pass the entry and mention the invoice numner in field Inv. Ref. under payment tab..
    Regards,
    Chintan Joshi

  • Sorting the year without affecting the tracks

    How do I sort the year from most recent to oldest without affecting the order of the tracks?

    The most recent albums at the top of the list is "last is listed on top", and apparently Apple has not set up a sub filter to list albums "last on top" while listing tracks "first on top".
    If you list Albums "first on top" then the tracks will also be "first on top".
    Yeah it's kinky.
    At the top of iTunes, click iTunes/Provide iTunes Feedback. Tell Apple what you think.
    Tracy

  • Mass Settlement of Trip without affecting the financial postings -- Travel

    Hi SAP Gurus ,
             This is Sudhir , I need to know whether any function module is available for mass settlement of trips (i.e changing the setellement status in table level as 2 without affecting the financial enteries).
    Generally the settlement of trips is generally done thorugh PR05 t code. Since I my company they are planning to migrate data from legacy to ecc6.0 , they have decided to settle all the trips before migrating. 
    I suggested  BDC operation , But my functional team told that It will affect the financial enteries.
    So friends , I am really held , Could you kindly sugget me how to proceed further.
    With Regards ,
    Sudhir S

    Hi SAP Gurus,
             Could you kindly suggest How to proceed further regarding this .
    With Regards ,
    Sudhir S

Maybe you are looking for

  • Using a UNIX shell script to run a Java program (packaged in a JAR)

    Hi, I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attache

  • Unknown username greyed out in Apple ID login window

    Good evening! When I am trying to install updates from my App Store, I get asked to sign into my accound, understandably. But this is what appears: A completely unknown email address is already typed in and greyed out so I can´t change it to my own.

  • Is Premiere Elements 8 organizer compatible with HDC-SD1 files?

    This is one of the original AVCHD camcorders.  I have the trial installed of Premiere Elements8.  When I load in the organizer, it opens up.  I click file>get videos from files/folders.  The importing seems to take "forever" - 15 short clips (<1-2 mi

  • Keeping Boxes Active while dragging Guides

    I am just starting to use AI CC version 18.0.0. In previous versions (CS 5.5) you could click on a box and the six little boxes would show...one on each corner and two in the middle. Then you could easily bring guides to the center of the box by drag

  • Editing in Photoshop loses edits previously made in Aperture

    Repeatedly after I have cropped and edited a photo in Aperture then selected Edit in Photoshop, once the image opens in photoshop, the edits are gone except for the crop. What is the issue?