JpopupMenu mouse hover visibility

Hi, I have a created a navigation window (north docked window) and am using JPopupMenu to act as the navigation per navigation field. I want to add a mouse listener to this JPopupMenu class so that when the user’s mouse is not hovering over the popup menu anymore the popupmenu disappears, similar functionality to most modern websites. Basically a mouseEntered and mouseExited function within the class. I have also added JMenu Items to this JPopupMenu so not sure if I need to add mouselisteners to each of their classes (not included in sample below).

Here is something that’s been started.

from java.awt.event import MouseListener
from javax.swing.event import PopupMenuListener

class MouseEventTest (MouseListener):
	def __init__(hello) :
		print "init"
	def mousePressed(hello,hello2):
		print 'mousePressed'
	def mouseReleased(hello,hello2):
		print 'mouseReleased'
	def mouseEntered(hello,hello2):
		print 'mouseEntered'
	def mouseExited(hello,hello2):
		print 'mouseExited'

def sayHello(event):
	print "function execution"
menu = system.gui.createPopupMenu(["Click Me"], [sayHello])
listener = MouseEventTest()

^not sure how to make it appear correctly indented
Also I do know that this system.gui.createPopupMenu() object is a Jython version of the JPopupMenu so they are not completely the same, but if I could keep using that it would be ideal because it has been easier to position.