[Richard Cook]
>if I write (in tst.py)
>
>from javax.swing import *
>b=JLabel("bob", displayedMnemonic=66)
>
>jython tst.py gives:
>
>Traceback (innermost last):
> File "tst.py", line 2, in ?
>AttributeError: read-only attr: displayedMnemonic
>
>If I have this:
>
>from javax.swing import *
>
>class Dummy(JPanel):
> pass
>
>b=JLabel("bob", displayedMnemonic=66)
>
>Then I get no complaint.
Strange. It seems like the sequence of reflected methods is different
when the Dummy class exists. I have no explanation for this at the
moment.
>Am I doing something wrong?
No, it is bug in jython. Feel free to add a bug report on sourceforge
with your example.
The bug is triggered because there is two setDisplayedMnemonic(..)
methods. As a result, jython can't decide what the type of the property
should be. Since there can only be one property with the name
'displayedMnemonic' it is either a read/write integer property or a
read-only character property. Which it is, depends on the sequence the
methods is returned from java reflection.
>Also, because displayedMnemonic is an int property,
>
>b=JLabel("bob", displayedMnemonic='b')
>fails (can't convert string to int)
>
>but
>b.setDisplayedMnemonic('b') works OK because presumably it calls
>setDisplayedMnemonic(char)
Right. Here the properties is skipped altogether and the method is
called directly.
regards,
finn
|