From: <bc...@wo...> - 2001-09-05 19:20:07
|
[Bill Kelly] >I'm writing Swing code and need to provide my own paintComponent() >method, which is required to invoke super.paintComponent() in most >cases (see >http://java.sun.com/docs/books/tutorial/uiswing/converting/generaltips.html >"Converting Painting Code") - but paintComponent() is a protected >method of JComponent, and I'm unable to invoke it from my jython >paintComponent method. I see in the jython docs on subclassing: > >Calling Methods in Your Superclass > > In Python, if I want to call the foo method in my superclass, > I use the form: SuperClass.foo(self) > > This works with the majority of methods, but protected methods > cannot be called from subclasses in this way. Instead you have > to use the "self.super_foo()" call style. The docs are wrong. It should read self.super__foo() (with two underscores). >Could someone post an example of this call style? I've tried >a couple things: self.super_paintComponent() and >self.JPanel_paintComponent() but no luck with either. (JPanel >being my direct superclass.) from javax import swing class MyComponent(swing.JLabel): def __init__(self): self.setText("Hello from jython") def paintComponent(self, g): print "paintComponent" self.super__paintComponent(g) import pawt pawt.test(MyComponent()) regards, finn |