How to call a Java superclass from jpython ??
Finn Bock
fbo at dde.dk
Tue Jun 22 06:38:15 EDT 1999
"Markus A. Greiner" wrote:
> I´m trying to port some java applications into jpython.
> Now I got a problem. I´m not able to call a java superclass from
> jpython.
> Did anybody know how to call them? Here the code I´m trying to convert:
>
> It´s from PropertiesMetalTheme.java of the JDK Metalworks example.
> In method initcolors:
>
> ...
> primary1 = super.getPrimary1()
>
> Everything I tried in jpython failed. In some other cases replacing the
> super call into a construct like:
>
> ...
> ParentClass.method(self)
>
> works fine, but in this case
>
> ...
> DefaultMetalTheme.getPrimary1()
I'm sure you mean
DefaultMetalTheme.getPrimary1(self)
But either way, it does not work in JPython1.1beta2
> and all other constructs failed. I´m using JPython 1.1 beta 2 so
> calls like self.super__method are obsolte and didn´t work anymore.
> (I think :-)) or better I tried without success)
The super__ methods should no longer be necessary, but they still work,
so as a temporary workaround you could perhaps use something like this:
from javax.swing.plaf import metal
class PropertiesMetalTheme(metal.DefaultMetalTheme):
def initColors(self):
self._primary1 = self.super__getPrimary1()
def getPrimary1(self):
return self._primary1
p = PropertiesMetalTheme()
p.initColors()
print p.primary1
BTW, the chance of an answer to jpython questions are much higher in
jpython-interest mail list.
--
Regards
Finn Bock
More information about the Python-list
mailing list