For the Easy Chart, I tested @pturmel's approach combined with @klpe's method for getting the radio buttons, and it works perfectly. However, if work is to be done with the code, there is no need to do the work every time the mouse enters the chart or every time the mouse enters some component on the chart, so rather than develop listeners, I simply added a custom component to the chart's parent container called oldMode. I then use the mode to evaluate whether or not work needs to be done at the mouseEntered event. Here is the code:
oldMode = event.source.parent.oldMode
def findJFChart(src):
try:
return (src, src.chart)
except: pass
try:
for x in range(src.componentCount):
try:return findJFChart(src.getComponent(x))
except: pass
except: pass
raise ValueError, "Unable to Find a JFreeChart Instance"
chart = event.source
ch = findJFChart(chart)
isPanned = ch[0].getPopupMenu().getSubElements()[0].getComponent().getItem(1).isSelected()
isZoomed = ch[0].getPopupMenu().getSubElements()[0].getComponent().getItem(0).isSelected()
isXtraced = ch[0].getPopupMenu().getSubElements()[0].getComponent().getItem(3).isSelected()
if isPanned:
newMode = "Pan Mode"
elif isZoomed:
newMode = "Zoom Mode"
elif isXtraced:
newMode = "XTrace Mode"
else:
newMode = "Mark Mode"
if newMode != oldMode:
print newMode
#do work HERE
event.source.parent.oldMode = newMode