Jython question concerning actionPerformed

Mishre mishre at hushmail.com
Mon Feb 4 07:25:42 EST 2002

I have the following code in Jython running on JDK 1.4, which looks
like it should work, but isn't:

def actionPerformed(self,event):
    if event.getActionCommand() == "Exit":
    elif event.getActionCommand() == "comboBoxChanged":
        print event

Then later on I have:

self.catCombo = javax.swing.JComboBox(actionPerformed=self.actionPerformed)

I'm trying to update a JList when the selected item in the JComboBox
is changed.  If I use the code above I get the following error when I
run the program:

"TypeError: can't assign to this attribute in java instance:

If I use:

self.catCombo = javax.swing.JComboBox(actionPerformed=self.actionPerformed())

I get:

TypeError: actionPerformed() takes at least 2 arguments (1 given)

This is because I have "def actionPerformed(self, event)" but I need
both of them or I can't look at the event.

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).

Does anyone have any ideas on what to try next?



More information about the Python-list mailing list