Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make JPopupMenu invisible?

 
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: 2564
9
  • 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: 2564
9
  • 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
Pie
Posts: 20511
54
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic