Skip to main content

Using the same PopupMenu behavior's on JPopupMenu TrayIcon [SOLVED]

3 replies [Last post]
Joined: 2010-06-29

Hi everyone,

I have a TrayIcon in my application with an event click to open a JPopupMenu. I need to reproduce the same PopupMenu's behavior, when my JPopupMenu is clicked, it execute something and close, or when the mouse clicks the outside of my JPopupMenu just close. Everything is working fine, only when the mouse click outside of my JPopupMenu this doesn't close, what can i do??

Thanks ALL

A invoker was setted in my JPopupmenu, but this invoker needs to be visible, so this one was configured very small[1,1] and showed behind my JPopupmenu, then i believed that this invoker catch's the lost focus events.

Message was edited by: brancaleone

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-03-24

Could be wrong, but it sounds like a focusing issue, the popup doesn't know that it's lost focus.

You could attach a focus listener to the popup and on focus lost, close the popup manually.

Just an idea

Joined: 2010-06-29

I cannot get the focus lost from my popup, still adding FocusListener on my class didn't work.. do you have an example???

Joined: 2011-06-28


i wrote this:

popupMenu.addFocusListener(new FocusListener() {

public void focusLost(FocusEvent e) {
System.out.println("focus lost");

public void focusGained(FocusEvent e) {
System.out.println("focus gained");

But in all cases i don't know why but it does not seem to work !

it does not show anything !