Calling PaintComponent in Jython
Samuele Pedroni
pedronis at bluewin.ch
Thu Aug 22 10:25:18 EDT 2002
Luiz Felipe Martins <fmartins at mindspring.com> wrote in message
ak2e6r$ivc$1 at slb7.atl.mindspring.net...
> I´m trying to do something like this:
>
> class MyPanel(javax.swing.JPanel):
> def PaintComponent(self,g):
> javax.swing.JPanel.PaintComponent(self,g)
> ...
>
def PaintComponent(self,g):
self.super__PaintComponent(self,g)
>This does not work because PaintComponent is protected. In the book Jython
>for Java Programmers (excellent, btw), R. Bill suggests either changing the
>Jython registry or to write a Java class to mediate access.
he should be talking about protected fields, for them at the moment
writing a mediating class is the only solution. Changing
respectJavaAccessibility
for production code is not a good idea in general and it interacts badly
with the shortcut for accessing properties:
public class Thing {
protected int value;
public int getValue() { return value; }
public void setValue(int v) {
// ... side-effects and change value
}
}
now with respectJavaAccessibility = true
(the default):
t=Thing()
t.value =3
effectively calls t.setValue(3)
but with respectJavaAccessibility = false:
t=Thing()
t.value =3
simply changes the protected value and
the side effects are not triggered :(.
If I (or someone) get at it, this should change, for normal
code written assuming respectJavaAccessibility = true
is not a problem, but it is for example
writing dev tools for Jython in Jython.
regards.
More information about the Python-list
mailing list