You can do it by creating your popup menu with the underlying java classes instead of system.gui.createPopupMenu(). If you look at JMenuItem, you’ll see it has a constructor that takes an icon and a string. You can use this code to get you started:
def showPopup(event):
if not event.popupTrigger:
return
from javax.swing import JPopupMenu, JMenuItem
menu = JPopupMenu()
x = JMenuItem("Show Tag Tree")
def showTagTreeAction(event, comp=event.source.parent.getComponent("TagTree")):
comp.visible = True
x.addActionListener(showTagTreeAction)
menu.insert(x, TagTreeIdx)
menu.show(event.source, event.x, event.y)
Note that the show() method for a manually constructed JPopupMenu is different.