This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to make JPopupMenu invisible? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 1808
    
    2
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: 1808
    
    2
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: 19232

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


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to make JPopupMenu invisible?
 
Similar Threads
Invisible Cursor
JTextField
select text in jtextfield, but only when tabbing
automatic scrolling of JTextField
Keyboard navigation in JPopupMenu