Delayed Gui Update / Observed effect / Timer problem

Hello-
I've a small jpanel I wrote that intercepts mouse clicks and performs some logic with them. When used independently on a jframe, it highlights where the user clicked with a red square.
I have since modified it to use a notification object so that I can tell a gui window when it has received a valid mouse click... but I need still to be able to display the red square and 'pause' for about 500ms before advancing to the next target.
Currently, when the high level GUI receives a notification of a valid mouse click it immediately goes to the next target. I'd like it to pause for 500ms... but if I use something similiar to Thread.sleep(500) or SwingUtilities.invokeLater the red patch won't show since it still takes time to update .
So.... suggestions as to how I can 'know' when my panel is presented properly and can pause before moving onto the next one?
Thanks in advance-
Jason

There's a 'target' on the screen consisting of a couple of boxes. When the user selects one, they turn red to notify they've been selected... and then about 500ms later you move onto the next 'target' (different look and feel, same handling).
Yes I've found out that sleeping and drawing in the same thread doesn't work at all ;)

Similar Messages

  • Making GUI update at correct time

    I'm creating an engine that can display experimental stimuli for my lab working with kids with reading disabilities. I have a GUI which can display the next stimuli in the test. Once the stimuli are displayed, the program does nothing until the user presses a button and a key event is called.
    I'm now trying to get my GUI to play recorded words to the user. Because it's the responsibility of the GUI to display stimuli, the GUI will be the one playing the sound (even though that's not typically thought of as a GUI responsibility). Unfortunately, even though the commands to update the GUI display are placed before the command to play the sound, the GUI does not update until it has finished playing the sound.
    This has nothing to do with the sound itself: if I replace the clip.play() line with a loop that wastes time and spins around for five seconds, the GUI does not update for those five seconds.
    The GUI updates itself the moment the program leaves the setStimuli() method. How can I get it to update itself before then? Commands such as this.repaint() don't appear to work.
    Any thoughts on how to get the GUI to update itself before exiting the method?
    public class TestingEngine {
    public void setStimuli(String[] values) {
       gui.setStimuli(values);
    public class GUI extends javax.swing.JFrame {
    public void setStimuli(String[] values){
           switch (testType){
             case SOUND:
                   String soundImageFile = "Headphones.jpg";
                   ImageIcon soundImage = new ImageIcon(soundImageFile);
                   JLabel soundImageLabel = new JLabel(soundImage);
                   SoundImageJPanel.removeAll();
                   SoundImageJPanel.repaint();
                   SoundImageJPanel.add(soundImageLabel);
                   soundImageLabel.setVisible(true);
                   label_S_Option1.setText(values[1]);
                   label_S_Option2.setText(values[2]);           // <-- nothing has updated yet
                   SoundClip clip = new SoundClip(values[0]);
                   if (clip.isInitialized())                     // <-- this section could also be replaced
                       clip.play();                             // by a time-wasting loop
                   break;
        }      // <-- once program reaches here, GUI finally updates
    }

    Ok, so just for the sake of it, I tried using the Timer method as suggested in the thread you pointed me to. This doesn't do anything, but thinking about it, I don't see why it would. Timer calls repaint() every 50 ms, but, after all, the setStimuli() method also called repaint() before playing the soundclip. If the original call of repaint() didn't do anything, then I don't think that calling it more often would.
    Is there another command that I should be using? In other words, how can I tell my JFrame and JLabels to "UPDATE RIGHT NOW, NOT IN A MINUTE!"? (It would be easier if I were the JFrame's mother...)
    Current version of code, with Timer class:
    public class GUI extends javax.swing.JFrame {
       private Thread refresh;
       public GUI() {
           initComponents();
           refresh = new Timer(this);
           refresh.start();
       public void setStimuli(String[] values){
           switch (testType){
             case SOUND:
                   String soundImageFile = "Headphones.jpg";
                   ImageIcon soundImage = new ImageIcon(soundImageFile);
                   JLabel soundImageLabel = new JLabel(soundImage);
                   SoundImageJPanel.removeAll();
                   SoundImageJPanel.repaint();
                   SoundImageJPanel.add(soundImageLabel);
                   soundImageLabel.setVisible(true);
                   label_S_Option1.setText(values[1]);
                   label_S_Option2.setText(values[2]);           // <-- nothing has updated yet
                   SoundClip clip = new SoundClip(values[0]);
                   if (clip.isInitialized())                     // <-- this section could also be replaced
                       clip.play();                              // by a time-wasting loop (same problem)
                   break;
       }      // <-- once program reaches here, GUI finally updates
       public void callback(){
           repaint();
    class Timer extends Thread
         private Gui parent;
         public Timer(Gui g) {
              parent = g;
         synchronized public void run() {
              while(true) {
                   try{
                       wait(50);
                   }catch(InterruptedException ie) {return;}
                   parent.callBack();
    }

  • I am using Windows 7 Home Premium 64-bit OS.  I've never had this problem before... today I opened iTunes and it prompted me to download the newest version.  I use iTunes all the time and have updated it multiple times with no issues.  During the installa

    I am using Windows 7 Home Premium 64-bit OS.I've never had this problem before... today I opened iTunes and it prompted me to download the newest version.  I use iTunes all the time and have updated it multiple times with no issues.  During the installation process it gave me an error message that said: 
    Runtime error! 
    Program C:\Program Files\iTunes.exe
    R0634
    An application has made an attempt to load the C runtime library incorrectly.
    Please contact the application's support team for more information.
    I quit the installation, uninstalled iTunes and rebooted my computer.  I now receive a similar message with a slight difference:
    Runtime error! 
    Program C:\Program Files (x86)...
    R0634
    An application has made an attempt to load the C runtime library incorrectly.
    Please contact the application's support team for more information.
    I did not leave anything out from the error message.  It doesn't point to a specific file, it just ends with "(x86)..."  Every time I boot up my computer, this error message pops up on my desktop.
    How do I repair this issue?  I have found multiple suggested solutions but am unsure which one is the best, and I don't want to try a bunch of different things for fear I may make the problem worse.  I would like to try and fix this myself if possible but I need to know if that is really possible or if I need to take my computer to someone for repairs.  Any suggestions will be greatly appreciated!!

    Hi lustyln,
    I'm having a little trouble understanding all of what you are trying to explain. From what I can tell, it sounds like your PC has a lot of software problems and you want to know what is supposed to be there and what isn't.
    For reference, here are your product specifications:
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&dlc=en&docname=c01893242&lc=en&product=4043282
    To get your PC software back to how it was when it was first purchased, run a system recovery:
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&dlc=en&docname=c01867418&lc=en&product=4043282
    I hope this helps.
    ...an HP employee just trying to help where I can, but not speaking on behalf of HP.

  • Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    You might find useful information in item D1 of Time Machine Troubleshooting.

  • In my iphone4s and  my iPad every time who I ask an update or down load an application ask me a bill account at the past I have not a problem to downloaded any application or update until one time I bought one application

    I try to downloaded any application or update to my iPhone or my iPad but asked me a billing acount. In the past any time who I asked any application or updated it was free  until one time  I bought one application with my bank debit cards once every time since then every time I want to download an application or update shows my account problem and not receive another card.

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Problem updating After Effects CC (2014)  I get this message: Update Failed  Error encountered during installation. (U44M1P7)

    Problem updating After Effects CC (2014)  I get this message: Update Failed  Error encountered during installation. (U44M1P7)

    Hi,
    It’s version 13.1.1  It’s a trial version.
    I am updating it from the Creative cloud desktop application.
    I have the photography subscription with Lightroom and Photoshop with Creative Cloud.
    I was interested in trying out the video software and have trials of Premiere Pro as well as others.  The CC desktop app alerted me to the AF update just as it does for the others I subscribe to plus the ones I am using as trials.  I have not had any problems with the other apps (trial or not), only with AF.
    Thanks.
    Nancy Chadwick

  • X301 post BIOS / Model Number update System Time problems

    Dear community,
      I recently updated my BIOS using the thinkvantage flash BIOS utility for no reason other than it appeared on the update utility. I also updated the model number, once again for no real reason other than update pleasure. Now, everything works perfectly fine on the system, and I have no problems EXCEPT:
    I use New York Times Adobe Air product called "Times Reader". Since the update, when I try to log into the Times Reader I get an error that states "Authentication Error. Check that your system time is set correctly." In the pre-boot set up screen the time seems to be set right, and in the windows utility the time is set correctly. So my questions is,
     after a BIOS flash / Model # update, does the system time function need some re-boot / update? 
    Thanks! 

    Well I still dunno what the problem was.  It seemed as if the system would have to be running for a day or two before it would start to speed up, as if it was actually gaining a few milliseconds cumulatively every second...
    Anyway, through other testing (OC & such) I flashed to 1.5B5 and it is running pretty good, and seems to have fixed the time problem.
    On a side note, 1.5B5 is the first BIOS that actually makes Cool 'N Quiet work (to underclock to 1GHz at idle & dynamically OC when needed).
    If anyone has experienced this time issue, please post findings!  For now, it's fixed for me, so I'm not going to worry about it  

  • I have iWorks for a Mac Mini, I want to install that software on my MackBook Air, but it keeps telling me to update the software, I have updated it several times. Still no go, any ideas how to get past this problem? Thanks!

    I have iWorks for a Mac Mini, I want to install that software on my MackBook Air, but it keeps telling me to update the software, I have updated it several times. Still no go, any ideas how to get past this problem? Thanks!

    Movies are not bought via Netflix, then are rented or borrowed.
    For iTunes account issues, contact iTunes Customer Support.

  • I've tried and tried several times to Connect my device to my PC and follow the onscreen instructions in iTunes to download the update from Apple. Problem is iTunes doesn't connect to my iPad so that I can update to iOS 5. I don't see the iPad icon when

    I've tried and tried several times to Connect my device to my PC and follow the onscreen instructions in iTunes to download the update from Apple. Problem is iTunes doesn't connect to my iPad so that I can update to iOS 5. I don't see the iPad icon when iTunes loads. I have looked in my computer and see the iPad is recognized. Any one else having this problem? This is also happening with my iPod
    Thank you, Ripley

    I haven't updated yet. Apple's download servers have been too busy. Did you know you can update via wifi instead of connection to your computer?
    Here's a description of the update. Not a lot of changes for iPad 1/2.
    iOS 5.1 Software Update
    http://support.apple.com/kb/DL1504
    You can wait a while & update at your convenience.
     Cheers, Tom

  • Was there a problem with the last update? Every time I try to watch a video on the net it goes back to the home screen

    Was there a problem with the last update? Every time I try to watch videos it goes back to the home screen

    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • The ios8 update is causing innumerable problems with my ipad. The info from my calendar just disappeared, I am typing blind with the keyboard most of the time, and I cannot upload pics or paste to FB. When will this be fixed and what can I do in the

    The ios8 update is causing innumerable problems with my ipad. The info from my calendar just disappeared, I am typing blind with the keyboard most of the time, and I cannot upload pics or paste to FB. When will this be fixed and what can I do in the Meantime?

    Have you tried yesterday's update to iOS8.0.2?
    iOS 8.0.2
    This release contains improvements and bug fixes, including:
      •  Fixes an issue in iOS 8.0.1 that impacted cellular network connectivity and Touch ID on iPhone 6 and iPhone 6 Plus
      •  Fixes a bug so HealthKit apps can now be made available on the App Store
      •  Addresses an issue where 3rd party keyboards could become deselected when a user enters their passcode
      •  Fixes an issue that prevented some apps from accessing photos from the Photo Library
      •  Improves the reliability of the Reachability feature on iPhone 6 and iPhone 6 Plus
      •  Fixes an issue that could cause unexpected cellular data usage when receiving SMS/MMS messages
      •  Better support of Ask To Buy for Family Sharing for In-App Purchases
      •  Fixes an issue where ringtones were sometimes not restored from iCloud backups
      •  Fixes a bug that prevented uploading photos and videos from Safari
    For information on the security content of this update, please visit this website:
      http://support.apple.com/kb/HT1222

  • I cant use my fire fox continuously ,after some time its automatiocally restarted i update also but the problem not solved,pls give solution for that issues?

    hi
    when i enter into fire fox for 15 min no problem i can use after that its restarted, i update also,but the problem occur again.......
    i cant solve this problem, i have added many password, i cant make re install,

    What issue occurs after about 15 minutes? Do websites stop loading? Does Firefox crash?
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/faq/?qid=208283363 TDSSKiller - AntiRootkit Utility]
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • Payment budget is getting updated at the time of Invoice

    Hi,
    I have a peculiar problem in Funds Management. As per the client requirement payment has to made in split i.e. 90% and 10% against the invoice amount raised. But, payment budget is getting updated at the time of invoice itself when i use the profile of 00350.
    It is observed that at the time of payment, the payment budget is not getting updated and updating at the time of invoice creation itself. So, when we developed customised report, we had given payment budget filed to know the current month expenditure. But the problem is as per cleint requiremnt, the payment budget has to update at the time of payment but not at the time of invoice creation.
    Please advice me is there any way to solve this problem.
    Thanks & Regards
    Vijaybhaskar

    This is standard; payment budget is updated during the invoice issue. What is done with the payments is 'payment transfer'; it could be either manual (via FMF0) or automatic - depending on your settings in FM. In your reprots you can define to see only 'cleared' invoices in FM, i.e. those, for which the payment transfer has been completed. However, the availability control will be still performed already on invoice phase.
    Hi,
    As suggested by you i have done automatci payment ransfer in OF29 and made value type 54 as stastical and 57 value type for payments.
    As you suggested "In your reprots you can define to see only 'cleared' invoices in FM, i.e. those, for which the payment transfer has been completed.".
    Please expalin where can i look clered invoices in FM, .e. those, for which the payment transfer has been completed."
    Regards,
    vijay

  • Errors occurred while installing the updates. If the problem persists,

    Hi,
    My iPod Touch 4th generation has the update version 4.2.1 (latest is 5.something) and needs nearly a half GB update. Every time I try to update iTunes (uninstalled and reinstalled last two) or my iPod. I get the error in the heading or ""iTunes" has an invalid signature. the download has been removed."
    I have done all the following as stated in the Apple help
    1. Empty your Temp directory and restart
    2. Completely remove iTunes and related components
    3. Install the latest version of iTunes
    1. Make sure you have administrator account access
    2. Make sure your folder names don't contain strange characters
    3. Get the latest Windows updates
    4. Disable other conflicting software
    I have even gone in and selected, though I don't remember where "Allow downloads with invalid signature" (to that effect)
    I just read that it might be a router problem so I bypassed my families wireless router and plugged in a hard line. Didn’t work. If no advice comes from here, I will try again on the school network next Tuesday…
    Advice? Thoughts? Ideas?
    Alex

    Apple digitally signs its software updates to ensure the authenticity of update packages.  When you receive an "Invalid Signature", that means the software package may not be legitimate.  But then of course, many a times, it's a false alarm from other problem.
    I would suggest you to Uninstall everything and reinstall from scratch but follow the following steps:
    1. Go to Microsoft website to fix install and Uninstall problems. Click "Run now" from Fix it to remove all iTunes & related installer files.
    http://support.microsoft.com/mats/Program_Install_and_Uninstall
    Be aware that Windows Installer CleanUp Utility will not remove the actual program from your computer. However, it will remove the installation files so that you can start the installation, upgrade, or uninstall over.
    2. You should remove all instances of iTunes and the rest of the components listed below:
    it may be necessary to remove all traces of iTunes, QuickTime, and related software components from your computer before reinstalling iTunes.
    Use the Control Panel to uninstall iTunes and related software components in the following order:
    iTunes
    QuickTime
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Follow the instructions from Apple article listed here: http://support.apple.com/kb/HT1923 to remove all components
    3. Reboot your computer. Next, download iTunes from here:http://www.apple.com/itunes/download/ and install from scratch

  • Suspending GUI update

    I have an app which runs a background thread. While the thread is running I want to disable various clickable GUI elements. My problem is that the elements all disable rather slowly and it looks funny (they don't all disable simultaneously). Is there a way I can suspend GUI update, set all my elements to disabled, and then force the GUI to update them all at once?

    Well I'm actually doing this:
    @Action
    public Task runSimulation() {
        SimulationTask simulationTask = new SimulationTask();
        // some code to init my Task
        for (JPanel panel : playerPanels) { // playerPanels is a JPanel[10]
            panel.setEnabled(false);
        return simulationTask;
    }So the code to disable the panels runs before the task is even started. I tried adding the disabling code to the doInBackground method of my TaskListener attached to simulationTask but the delay is worse. The panels disable almost simultaneously using the above method but are out of sync just enough to make everything look amateurish and poorly done.
    As a side note this is written using the swing application framework in netbeans. The runSimulation method is attached to a button that runs a pretty CPU intensive task in the background.

Maybe you are looking for