Hi all,

I'm trying to implement a subclass of JLabel that extends JLabel to notice mouse clicks.  I found a tutorial that explains how to do this (in Java) here: http://www.faqs.org/docs/javap/c7/s4.html

The main points seem to be declaring the class like this:

public class StopWatch extends JLabel implements MouseListener

followed by calling "addMouseListener(this)" in the constructor, and implementing a few "mouseXxxx" methods.

I tried to follow this pattern in jython by doing this:

class ClickableLabel(JLabel):
    def init(self):
       JLabel.init(self)
       self.addMouseListener(self)
   
    def mousePressed(self, evt):
        print "clicked"
   
    def mouseReleased(self, evt):
        pass
    def mouseClicked(self, evt):
        pass
    def mouseEntered(self, evt):
        pass
    def mouseExited(self, evt):
        pass

Unfortunately it doesn't work.  That is, I can create an instance of this and put it in a window, and it behaves like a JLabel, but it doesn't print the message when I click.  My best guess is that this has something to do with the "implements MouseListener" in the Java version, which I'm not doing anything to match in the jython version.  Is there some particular way of declaring that my class implements a Java interface?

--
// jack
// http://www.nuthole.com