Jython question concerning actionPerformed

Jason Orendorff jason at jorendorff.com
Mon Feb 4 20:00:23 EST 2002


Mishre wrote:
> self.catCombo = \
>     javax.swing.JComboBox(actionPerformed=self.actionPerformed)

Unfortunately JComboBox has a public method named actionPerformed.
Jython apparently thinks you're trying to assign to that.

Alas, it seems you'll have to use self.catCombo.addActionListener()
just like an ordinary Java programmer.  (sigh)


> I've also tried this with the actionPerformed function declared
> as a class inheriting java.awt.event.ActionListener, which works
> a little better..but then I can't manipulate the self.catCombo
> item in the main function (or at least if I can I don't know how).

Easy: when you create the ActionListener instance, assign an
attribute on it that refers to the JComboBox object.

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list