GUI update problem: button take time to be disabled

I have a Stop button. In the actionPerformed() method for the button, I disable the button and also some other buttons (using setEnabled(false)) then there are some other codes that include Thread.sleep() method. Then again I enable some other buttons. Problem is the Stop button take time to be disabled. The time exactly equals sec provided in the sleep() method. I tried by puting the button disabling buttons' code in another thread that is called from SwingUtilies.invokeLater() method just before the sleep() method. It is very important to disable some buttons before Thread.sleep() is called. And only after the sleep() method I can enable some other buttons.
Please help me.

Hello Experts! I can't hear you. 1) Swing related questions should be posted in the Swing forum
2) Quit bumping your question, you only posted it 30 minutes ago. People will answer when they have the time.
Your code in the actionListener needs to be executed in a separate Thread, so that when you invoke the "sleep" method the separate Thread sleeps, not the Event Thread.

Similar Messages

  • HT4972 my ipod setting are missing softwhere update and it takes time to do from computer what do i do my ipod is 3g and i want ios 5?

    my ipod setting are missing softwhere update and it takes time to do from computer what do i do my ipod is 3g and i want ios 5?

    Until your iPod Touch is using iOS 5 or higher there is no way to upgrade without using iTunes on your syncing computer.

  • 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 ;)

  • 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 mean that i phone take time to open apps ,contact ,etc why? i close all apps and the problem still?

    i mean that i phone take time to open apps ,contact ,etc why? i close all apps and the problem still?

    Try a reset by pressing and holding the home and power buttons for 15-20 seconds until the white Apple logo appears.

  • I always update my iPad without any problem , but this time for the iOS 7 , it is still downloading from yesterday more than 24 hours and as a result I can't open any email . So can you help me or tell me what went wrong

    I always update my iPad without any problem , but this time it didn't work out . My iPad 4 is still downloading from yesterday and I can not meanwhile open any website or any mail . Can you tell me what went wrong ??

    Try reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • I can't seem to update my software, every time I do it says that there is a problem and to close everything that is open. Once I close everything it still doesn't work. How do I get it to complete?

    I can't seem to update my software, every time I do it says that there is a problem and to close everything that is open. Once I close everything it still doesn't work. How do I get it to complete?

    Make sure there's enough free space on the startup disk to install software updates...
    Right or control click the MacintoshHD icon. Click Get Info. In the Get Info window you will see Capacity and Available. Make sure there's a minimum of 15% free disk space.
    Freeing Up Hard Disk Space - Mac Guides

  • There is no option to reject an incoming call in locked screen, there must be an icon on the screen for one who don't want to use lock button several times, i did'nt face this problem in last ios 6.1.3.

    There is no option to reject an incoming call in locked screen, there must be an icon on the screen for one who don't want to use lock button several times, i did'nt face this problem in last ios 6.1.3.

    A good read. Have you done anything at all to resolve your problem. Reset? Restore?
    By the way - "your products"... nobody here produced the iPhone, we are all just users. Apple is not here.

  • Problems with my Time Capsule since updated to Mountain Lion

    Since I have updated my MacBook Air (late 2010 model) to OS X Mountain Lion, I am experiencing problems connecting my Macbook Air to Time Capsule and experiencing problems in Time Machine copies to the Time Capsule:
    1.- When I turn on my computer, Time Machine starts working, taking a lot of time searching the backup disc (my Time Capsule), then appears an error message (Can not find the disk or it says that the Time Capsule is already in use);
    2.- After several attemps (restarting the computer and restarting the Time Capsule), sometimes Time Machine starts to work, but it shows that it has to copy approximatly 28 G. Also the copy is to slow (it only copied 500 Megabytes in two days).
    In the meanwhile the Time Capsule light is turned on (green) - so it seems the Time Capsule is working normally an the problem would be Time Machine.
    I would not like to restart everytime my Time Capsule or restart my computer in order to make Time Machine works. I would really appreciate help for solving this problem (I apologize for my so basic English).
    My Airport Utility Version is 6.1 (610.31)
    My Time Capsule Version: 7.6.1.
    My Computer: MacBook Air (late 2010)
    My System: OS X Mountain Lion (when I used OS X Lion all was working normal)
    Thanks in advance for your help !!!

    The first backup after an update will be quite slow (but shouldn't be anywhere near that slow).  And the searching on the backup disk will have to be repeated on every backup attempt until one completes normally.
    Connect to the TC via an Ethernet cable. 
    Also see the green box in #D2 of Time Machine - Troubleshooting.  Something there may help get back on track.
    (and your English is fine -- better than many who speak it natively, I'm sorry to say.)

  • Share button on Toolbar when clicked takes time to load ? Do you get that ?

    Share button on Toolbar when clicked takes time to load ? Do you get that ?

    After activating your iPad, go to the App Store and search for your free apps:
    1. Pages
    2. Numbers
    3. Keynote
    4. iPhoto
    5. iMovie
    6. GarageBand
    If apps are still showing the price: sign out>reboot>and sign in again
    Settings>iTunes and App Store>Apple ID

  • After Updating Adobe Indesign CC ,While I'm selecting text in a paragraph, the text disappears and this problem repeated several times before update everything was ok

    After Updating Adobe Indesign CC ,While I'm selecting text in a paragraph, the text disappears and this problem repeated several times before update everything was ok

    First, see Replace Your Preferences and do it for the original account.
    If that fails to solve the problem, rename the two Adobe folders that contain the prefs in the user profile for that account and copy the folders from the new account where it works. You want to be sure you copy the folders, rather than merge the contents, so you must rename the old folders first.

  • Run time update on Button name and Action of Button

    I want to change the button name and button path in the GUI directly. So user can update GUI as per their requirement.
    Now I have built a GUI with multiple buttons. Whenever the button clicked corresponding webpage will be opened. This Button name and webpage link can not be changed as per current GUI design.
    But I want to allow anybody to update the Button name and webpage link as per their need.
    Please suggest , how can I achieve it? Please share if you have some code snippet.

    Changing the text on a Swing JButton is pretty simple. That isn't an appropriate question for this forum, however. This forum is for questions concerning using or extending WindowBuilder. General Swing questions should be posted to a general Swing/Java forum.

  • I can't update my apps. I touch the "Update All" button; it asks me for my Apple ID password but after I enter it nothing happens. I tried to update apps one by one but same problem continues.

    I can't update my apps. I touch the "Update All" button; it asks me for my Apple password but after I enter it nothing happens. I tried to update apps one by one but same problem continues. Help please

    The app that does not want to update was it originally downlaoded with a different ID?  If so use that ID and hte password you set for it to update the app

  • Why must I click the button two times to update the data?

    Dear All,
    I have written a simple vi about event case. I have found that I must to click the button two times to updata the data. I don't know why.
    And I can't use the stop button to stop the vi.
    Could you tell me the reason?
    Thank you very much.
    Attachments:
    event case.vi ‏42 KB

    Hi,
    1 : you have a "timeout case" but no timeout linked, so you lose the advantage of the event structure !
    2 : make a event for "stop" on value change
    3 : its normal, because le control terminals were out of the event struct, run it in high light mode you'll understand
    Remark : instead of having to clic a boolean to refresh the indicators, why don't you make a "value change event" directly on the control ?
    I modified your VI following step 1,2,3 above
    Hope this helps
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
    Attachments:
    event case.vi ‏17 KB

  • I have an iPhone 4 and since I updated to iOS6 I must hit the home button several times to return home or sometimes turn off and then back on. Any thoughts? Could this be related to running low on available storage?

    I have an iPhone 4 and since I updated to iOS6 I must hit the home button several times to return home or sometimes turn off and then back on. Any thoughts? Could this be related to running low on available storage?

    Hold the sleep/wake button and the home button until the phone shuts down and let it restart.

Maybe you are looking for

  • How to mount LinkStation LS421D volumes onto Mac desktop?

    Hello, How can I mount folders that I create on an LS421DE8AF onto the Mac OS desktop? I can't seem to get it to work. The Navigator software asks me to choose volumes I want to mount but nothing happens and then the selected folder remains greyed ou

  • Adobe PSE 11 installer defaults to the "uninstall" routine.

         I'm trying to install PSE 11 from a downloaded < Adobe_PE11_T1.zip >.  Preferring a "clean" installation, first I uninstalled PSE 10 (Windows7 Control Panel / Programs); however, PSE 10's program folder did not delete.  So, I deleted it manually

  • Modifying Flash Video Sound Track

    Hi Having a problem with my video. I'm doing a projector file, so I'm importing the video into the library so that I don't have any external files to deal with. When I import the video the sound is really quiet. I've tried bumping up the volume in iM

  • Multiple tools not working correctly in CS4

    Hello! So I didn't see any topics that related to my issue so here goes: I was drawing in Photoshop, no issues, but after I tried to copy/paste a selection of the picture, I realized that nothing was copying or pasting at that. (Now before anyone ask

  • Virtual keyboard in wrong place

    My keyboard keeps popping up in the top middle of the screen no matter which orientation I use, I have rebooted several times this does not help, close out all my apps and does not help, all apps experience this problem so lastly I just did a full re