I met a strange problem on JDialog. I have a swing application, using JDK1.3, eclipse 2.1.3 as my developing tool. I have a dialog extends from JDialog, which is supposed to pop up for "yes" and "no" choice. Everything works fine if I invoke the application from "debug" mode. However, if I invoke the application from "run" mode, everything works fine too if I use mouse clicking, but if I just use keyboard input, the dialog works fine first time, after the first time pop up, the dialog seems accept the "Enter" key automatically somewhere, so that the dialog closed immediately after "show" method is called, before I got a chance to press any key. And the dialog always selects "yes" automatically.
Really appreciated if anyone has any clue.
Thanks a lot in advance David Chen
Joined: Jan 06, 2002
The problem seems that a keyevent was not consumed by the other GUI component. In my swing application, I have a combobox, by using keyboard only, after I choose an item in combobox and press "Enter" key, the dialog is supposed to be popped up with "Yes" and "No" choice. The problem seems like that: 1. the combobox has keyPressed() defined (with keyReleased() empty); 2. the following dialog class has keyReleased() defined (with keyPressed() empty); 3. So, after press "Enter" key in combobox, KEY_PRESSED event is consumed by combobox in its keyPressed() but KEY_RELEASED event is not consumed for some reasons I don't know, which causes the problem that the dialog's method keyReleased() is trigged automatically by that event. And, after I move those logic in dialog class from keyReleased() to keyPressed() everything works fine. However, I'm still not very sure why that KEY_RELEASED event is not consumed by the combobox (I did define an empty keyReleased() method in combobox)? Or it may come from other reason?
Really appreciated if anyone can clarify me on that issue.
Thanks a lot David
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com