permaculture playing cards*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make JPopupMenu invisible?" Watch "How to make JPopupMenu invisible?" New topic
Author

How to make JPopupMenu invisible?

Andrei Mura
Greenhorn

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: 2152
    
    7
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: 2152
    
    7
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

Joined: Oct 27, 2005
Posts: 19649
    
  18

What Rob was referring to is http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make JPopupMenu invisible?
 
Similar Threads
Keyboard navigation in JPopupMenu
Invisible Cursor
JTextField
select text in jtextfield, but only when tabbing
automatic scrolling of JTextField