Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make JPopupMenu invisible?  RSS feed

 
Andrei Mura
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added to a JTextField a JPopupMenu.
Unfortunatelly, when i change the focus from JTextField, or when i "minimize" the window, the JPopupMenu still is visible.
I need to make it invisible if JTextField is loosing the focus.
How can i do this?
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you can add a FocusListener to the text field. When the focusLost() event is fired you get the source which will be the text field and then get the parent which should be the popup menu which you can then hide manually.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross post: http://stackoverflow.com/questions/1920787/how-to-make-a-popup-menu-added-to-a-jtextfield-to-be-invisible-when-the-jtextfiel

Good to know I wasted my time answering a question that has already been answered. That won't happen again.

ignoreList++
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Rob was referring to is http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!