aspose file tools
The moose likes Swing / AWT / SWT and the fly likes How to make JPopupMenu invisible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make JPopupMenu invisible?" Watch "How to make JPopupMenu invisible?" New topic

How to make JPopupMenu invisible?

Andrei Mura

Joined: Nov 26, 2009
Posts: 18
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

Joined: Jun 13, 2009
Posts: 2241
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

Joined: Jun 13, 2009
Posts: 2241
Cross post:

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

Rob Spoor

Joined: Oct 27, 2005
Posts: 19845

What Rob was referring to is

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: How to make JPopupMenu invisible?