I have an application, with a JTextField when that textfield gained focus, a popup menu is shown, and when it lost focus, the popup menu is hidden. My focus listener class is listed below, where popup is JPopupMenu, and function displayPopup() is just to call show() in JPopupMenu:
Everything works fine in jdk 1.3 version. In jdk1.4_2 version, I met following issues: 1. whenever the text field gained the focus, the application keeps calling "focusGained()", and "focusLost()" functions endlessly (it seems the system keeps sending those focus events endlessly); 2. if I removed that "popup.setVisible(false)" in focusLost, then, it seems no other component can gain the focus anylonger.
So, very appreciated if anyone can give me some help, is that a bug in 1.4.2 or is there any way to work around?
Thanks a lot
Joined: Jan 06, 2002
I just wonder, does that mean when JPopupMenu.show is called, the "lost focus" event is sent to invoker, and when JPopupMenu is hidden, the "gain focus" event is sent to its invoker again?
displayPopup gives focus to popup and your textfield looses focus and calls popup.setVisible(false) which gives focus back to your textfield which then calls displayPopup and ... you get the picture? When you remove popup.setVisible(false), your popup will have focus and have its own focuscycle