• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Focus problem in 1.4_2 when JPopupMenu show is called

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, there:

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

David
 
David Chen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Appreciated if any suggestion on this issue

Thanks a lot in advance
David
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic