Unable to close OK button of JOption dialog when 2 dialogs are displayed.

1. Run the below sample program
2. Click the "Click me" button immediately.
3. two dialogs are displayed, one by mouse click and another by threa.d
4. Now OK button of both dialogs are not working.
Expected behaviour:
the ok button of second dialog shold be active and should close the dialog.
Sample:
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class test
     public static void main(String arg[])
          MainFrame frm1 = new MainFrame();
          frm1.setVisible(true);
class MainFrame extends JFrame implements Runnable, ActionListener
     messagedlg errdlg = new messagedlg();
     JButton btn;
     MainFrame()
          btn = new JButton("Click Me");
          JPanel pnl = new JPanel();
          this.getContentPane().add(pnl);
          pnl.setLayout(new FlowLayout());
          pnl.add(btn);
          btn.addActionListener(this);
          setSize(400,400);          
          setLocation(400,200);
          Thread t = new Thread(this);
          t.start();          
     public void run()
          errdlg.showError(this,"mainscreen message");
     public void actionPerformed(ActionEvent ae)
          System.out.println("action start");
//          SwingUtilities.invokeLater(Thread.currentThread());
          errdlg.showError(this,"mainscreen action message");
          System.out.println("action end");
class messagedlg
     public static void showError(JFrame frame, String msg)
          try{Thread.sleep(1000);}catch(Exception ex){}
          Object[] options = {"OK"};
          int n = JOptionPane.showOptionDialog(frame,(Object)msg, msg,
               JOptionPane.OK_OPTION,1,
          null,     //don't use a custom Icon
          options,  //the titles of buttons
          options[0]); //default button title
}

Some things you need to know.
1. NEVER create or modify UI objects outside of the event dispatch thread (EDT) - you are doing this when you pop up the dialog on the new thread
2. NEVER sleep on the EDT - you are doing this when you respond to the action event
3. When you make mistake number 1, if you feed the same root frame to two modal dialogs on different threads then, well, on your head be it
Some reading for you, before you get into more trouble ;o)
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

Similar Messages

  • It's not showing the play or next song buttons on locks screen when the musics are played

    it's not showing the play or next song buttons on locks screen when the musics are played

    kaeandcolesmon,
    If you open the recovery drive (partition) it should only have a single folder (Recovery).
    To make sure that your not saving restore points to that drive.
    See:
    Start, Control Panel, System, System Protection tab. Make sure the D drive partition is set to OFF so that it does not save there.
    I am a volunteer. I am not an HP employee.
    To say THANK YOU, press the "thumbs up symbol" to render a KUDO. Please click Accept as Solution, if your problem is solved. You can render both Solution and KUDO.
    The Law of Effect states that positive reinforcement increases the probability of a behavior being repeated. (B.F.Skinner). You toss me KUDO and/or Solution, and I perform better.
    (2) HP DV7t i7 3160QM 2.3Ghz 8GB
    HP m9200t E8400,Win7 Pro 32 bit. 4GB RAM, ASUS 550Ti 2GB, Rosewill 630W. 1T HD SATA 3Gb/s
    Custom Asus P8P67, I7-2600k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX660 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Custom Asus P8Z77, I7-3770k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX670 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Both Customs use Rosewill Blackhawk case.
    Printer -- HP OfficeJet Pro 8600 Plus

  • I am unable to find "menu button New Fx Menu" when trying to (Click the menu button New Fx Menu and then click Exit Close 29)

    I have had sound problems when viewing facebook and youtube and thought it may be a plugin problem. I don't know much about computers and stumble my way through like now so simple instruction are required please.

    Hello,
    On the right side of your browser, below the window close button [X], should be three horizontal lines.
    * Menu [[Image: New Fx Menu]]
    * Exit [[Image: Close 29]] is on the bottom right corner of the menu that opens
    If you still cannot see it, '''try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that temporarily turns off hardware acceleration, resets some settings, and disables add-ons (extensions and themes).
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu:
    *Assuming you have your menu bar visible, go to "Help" > "Restart with Add-ons Disabled"
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    When the Firefox Safe Mode window appears, select "Start in Safe Mode".<br>
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, theme, or hardware acceleration. Please follow the steps in the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.
    If that menu is still not visible, please provide us with a screenshot. If you need help to create a screenshot, please see [[How do I create a screenshot of my problem?]]
    Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. This will help us to visualize the problem.
    Thank you!

  • Restored nano 6 but i am unable to use any buttons as nothing happens when they are pressed any ideas?

    Hi, i have a nano6 which i have restored. All songs etc have been loaded but  when i press the screen to play etc nothing happens. Any ideas

    Maybe try pressing both the vol. buttons as well as the power button at the same time.

  • How do I close multiple documents opened in Finder when the files are loading and the Application is not responding?

    I was moving 90 files from one folder to another and instead accidently double clicked all the files I had selected and they all opened at once and now they are all stuck trying to load and the program is not responding.
    When I put my mouse over the folders, it's just the loading cursor so i can't select anything. I've tried using 'command' - 'option' - 'W' and that doesn't work either.
    I have tried restarting finder and all that does is shut all of the folders and reopens them and they get stuck trying to load all over again.
    I have tried restarting my macbook and every time I log back in, it restarts all the programs and all the finder windows and the whole process repeats.
    (even when I unselect the 'restart opened programs' box.)
    I really hope someone knows how to troubleshoot this problem I am having!

    You're trying to use Spry Accordions for something they were never intended to do.   Why don't you switch to a more appropriate jQuery Mega Menu?
    http://www.designchemical.com/lab/jquery-mega-drop-down-menu-plugin/examples/
    In case you missed the announcement, Spry is dead.  Adobe abandoned it late last year because it has outlived its usefulness.
    http://blogs.adobe.com/dreamweaver/2012/08/update-on-adobe-spry-framework-availability.htm l
    Nancy O.

  • Unable to type from keyboard consistently in FF when certain sites are open (Lotus Domino Web Access)

    When I use FireFox to Open Lotus Domino Web Access after a few minute the browser will not allow me type consistently. This happened before around version 13 or 14 but went away. The mouse works perfectly except when clicking on window to open new tab.
    I have uninstalled, reinstalled current version 16.0.2
    I have uninstalled, reinstalled earlier version 14
    I have started in Safe Mode
    I have disabled all add-ins except for "Remote XUL Manager" which is necessary for Lotus Domino Web Access.
    I force closed using Task Manger and restart and it will work for a few minutes then start the same issue. I can not type "letter by letter" , if I hold a "letter" key down it will repeat the letter albeit at a slower pace.
    Unfortunately I installed Windows 8 which has IE10 (which cannot access Web Mail at all) so I have resorted to typing in a word document and pasting into emails within Lotus just to function.
    The site is not accessible for outside testing as it occurs post log in to site.

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    * Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    * Tools > Options > Privacy > Cookies: "Show Cookies"

  • Unable to close Modal dialog box

    Hello Friends,
    I am displaying a list in a Modal Dialog box. When I try to close the Modal dialog box. It is not getting closed.I have defined a gui status for this modal dialog box. PBO and PAI Coding is given below .
    module STATUS_0300 output.
      SET PF-STATUS 'STATUS_300'.
    SUPPRESS DIALOG.
      LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0 .
      IF p_week IS NOT INITIAL.
        WRITE : text-009 COLOR 1.
      ENDIF.
      IF p_month IS NOT INITIAL.
        WRITE : text-010 COLOR 1.
      ENDIF.
      LOOP AT g_t_wkmon_error INTO g_s_wkmon_error.
        WRITE :/ g_s_wkmon_error-matnr,
                 g_s_wkmon_error-period,
                 g_s_wkmon_error-quantity.
      ENDLOOP.
    LEAVE SCREEN.
    endmodule.  
    module USER_COMMAND_0300 input.
    CASE ok_code.
      WHEN 'OK'.
       LEAVE PROGRAM.
    ENDCASE.
    endmodule. 
    Thanks in Advance.
    Hari

    Hi,
    Check the below thread
    Re: Unable to close modal dialog box
    " Make sure you select the Radio Button DIalog BOX Typ while creating the Status in PBO
    You can use SET SCREEN 0 In the above Thread
    MODULE user_command_0100 INPUT.
      CASE ok.
        when 'CANCEL'. " You Standard GUI options shown in The GUI Screen
          SET SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    module STATUS_0100 output.
    SET PF-STATUS 'ABC'. " This is of type Dailog Box type
    *  SET TITLEBAR 'xxx'.
    endmodule.                 " STATUS_0100  OUTPUT
    Hope this would resolve your Issue.
    Cheerz
    Ram
    Edited by: Ramchander Krishnamraju on Apr 16, 2010 1:16 PM

  • Unable to close some custom forms

    Hi Gurus,
    We did application migration from Hp-Unix to Sun Solaris. Oracle apps 11.5.10.2 with database 10.2.0.4 and application working good with few issues.
    Issues:
    1. Few custom forms ( message Forms) unable to close. If we close by clicking X mark on top right corner, it does not close can just minimise.
    2. Couple of Custom forms does not open even we have .fmx in the custom folder.
    Need some suggestions on this issues.
    Thank You.

    f60gen module=ARXCUDCI.fmb userid=apps/apps output_file=/ul01/app/applmgr/lasrx/au/11.5.0/forms/US/ARXCUDCI.fmx
    Compiling ON-DELETE trigger on CODE_ASSIG_HIST data block...
    No compilation errors.
    Compiling WHEN-BUTTON-PRESSED trigger on BP_CLOSE item in CODE_ASSIG_HIST data block...
    No compilation errors.
    Compiling WHEN-NEW-ITEM-INSTANCE trigger on CURRENT_RECORD_INDICATOR item in CODE_ASSIG_HIST data block...
    No compilation errors.
    Compiling WHEN-MOUSE-UP trigger in FOLDER_PROMPT_MULTIROW property class...
    No compilation errors.
    Compiling WHEN-BUTTON-PRESSED trigger in FOLDER_OPEN property class...
    No compilation errors.
    Created form file /ul01/app/applmgr/lasrx/au/11.5.0/forms/US/ARXCUDCI.fmx
    Thanks You.

  • Unable to close iPad2 attachments

    I am brand new to the apple community, so please bear with me for the newbee question.
    After configuring my brand new iPad2 yesterday to sync with my mail provider, I opened an email attachment and I am unable to close it.
    When I press and hold the top of the attachment a keyboard dropdown appears, but there is nothing else on the page.
    When I go back to the main menu and re-open email, the attachment is still there and I can't access the mailbox.
    Can someone point me in the right direction?
    Thanks

    When you tap on the attachment-while it is open-do you not see a blue "Done" button in the upper left corner? If so, tap it to close the attachment.
    If the mail app is frozen, you can force quit it and restart the iPad.
    Force quit the app by holding down on the sleep button until the red slider appears. Let go of the sleep button and then hold down on the home button until the app quits. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Or just quit the mail app this way and restart.
    In order to quit or close apps - Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • Unable to close windows

    I didn't find any other threads on this problem, so evidently it's just my system?
    A few days ago I installed the latest Tiger security patch (2007-009), Java 6 update and Quicktime 7.3.1 update.
    Since then I am unable to close ANY window in Safari. Safari seems to work fine otherwise. I can browse and open tabs and windows, and websites can create new windows, but then I can not close ANY of the windows. I can close tabs but not windows. When I click the Close button, nothing happens, and when I use ⌘+W, nothing happens.
    So, after a while of surfin' the 'net, I end up with a bunch of open windows of various sizes. When I re-open Safari, I get one new window with the Home tab.
    I just recently began using Safari again, because it's 3x faster than Firefox on my iBook, but now I've got this problem.
    Any ideas?
    I will likely be calling Apple Support today, although I hate to, as I've found them to be very unknowledgeable and unhelpful in the past.

    Hi,
    Go to these 2 locations to see if you have any 3rd party extensions and move anything present in them onto your Desktop to deactivate them:
    /Users/YourUsername/Library/InputManagers/
    /Library/InputManagers/
    Restart Safari to pick up the change. If it works now, you can try moving the items back one by one until you find the culprit.
    If that doesn't help, or you don't have those folders, one quick test you can do to help narrow down things is to try Safari in another user account. This will help us to know whether your problem is local to your account or system wide. If you don't have another account you can use System Preferences -> Accounts -> \[+\] to create a test one (and \[-\] to remove it if needed)

  • In Address book print window opened too large for window.  Unable to close

    Using Address book,   trying to print lables for a group, print window opened to large for window.... cannot cancel or close out.

    In general, in any window presented which calls for user action, if a button is highlighted (usually in blue if the OS is in charge) then pressing Return or Enter will do the same as clicking that button.
    Most of the time the highlighted button is the one which is most usable - the "Print" button in that dialog window, for example, or the "Save" button in a Save dialog window.
    The keystroke Command-. (Command-periodkey) will usually invoke a "Cancel" button if such is present in a window.

  • My ipod is telling me there is not enough storage and I cannot back it up as there is not enough icloud storage. I am unable to close the message or go onto settings.

    my ipod is telling me there is not enough storage and I cannot back it up as there is not enough icloud storage. I am unable to close the message or go onto settings.

    Try:
    - 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.
    - Then delete some stuff

  • HT4211 I am unable to close my computer...the message on the ipad says not enough icloud  storage and go to settings.  Unable to go to settings and it is frozen and unable to close down.

    I am unable to close my computer...the message on the ipad says not enough icloud  storage and go to settings.   Unable to go to settings and it is frozen and unable to close down. How do I fix this for the button won't turn it off?

    Don't try to turn the iPad off until you reboot.
    On your iPad, Did you try holding down on the sleep and home buttons at the same time until the Apple logo appears? If you didn't try it, go ahead and do it. Wait until the Apple logo appears on the iPad screen before you let go of the buttons.

  • IOS 8 unable to close safari page

    I am unable to close my safari page ,by Hand Gesturing.I have to close only ,by pressing Home button only.
    ANy adjustment to be made in settings.
    Device:-I padmini with Retina display.Recently Upgraded Software to i.o.s.8.0.0

    Inside Safari, just click on the lower right icon menu (two squares), it will pull your page back, then click the X arrow at the upper left of the page.

  • I am unable to close an application, even after using force quit

    I am unable to close an application called Spotflux, it says application not responding, so I tried using force quit, but it also didn't working.

    Press and hold the power button for a few seconds until the power shuts off, then release, wait a few more seconds, and press it again briefly to restart.

Maybe you are looking for