I have a button (ReCalc) which loads a dialog with a textbox. If I use the mouse to click 'ReCalc" and to click the 'OK' in the dialog then all is ok. If I put the focus on 'ReCalc' and hit 'Enter' then the dialog loads but the focus is not in the text box. I must put the focus there with the mouse. If I then hit 'Enter' the 'Recalc' button fires again and a second InputDialog opens. In order to get the 'OK' button to fire I must tab focus to it. The problem is then that the InputDialog closes and the 'ReCalc' button fires and a new InputDialog opens. The InputDialog does not appear to consume the Key action event. I get around it by setting the 'ReCalc' focusable and enabled properties to false after it has been activated. When the listener has finished my required action I then re-enable them. This has the benefit of making the 'OK' button in the dialog the default key. The Java API describes the OptionPane as being modal but this doesn't appear to be the case. Any comments appreciated. PS. Using Java 1.8.1 in Linux.
Ads