When a JPopupMenu appears i want to execute some code for it. I can't figure out what listener should i use to trigger when the JPopupMenu becomes visible!
Java - Triggering a JPopupMenu to execute code when it is shown?
176 views Asked by Brad At
2
There are 2 answers
0
On
what listener should i use to trigger when the JPopupMenu becomes visible!
In case you want the code to execute before the menu is visible so you can configure the popup you can add a PopupMenuListener
to the JPopup
. It supports 3 events:
- popupMenuCanceled
- popupMenuWillBecomeInvisible
- popupMenuWillBecomeVisible
You should register a property change listener.
In the listener you should check whether the new value of the event is
Boolean.TRUE
.