From: D-Man <ds...@ri...> - 2001-04-03 14:29:07
|
On Tue, Apr 03, 2001 at 10:21:29PM -0400, cindy wrote: | Hi again, | If I may reiterate what you said to help me understand.If module Foo.py | has the statement "enableEvents(AWTEvent.WINDOW_EVENT_MASK)" and | module Bar.py does a composite on module Foo.py, then I have to pass | the instance name to module Foo.py to qualify the method enableEvents() | thus | "instanceName.enableEvents(). If this is so how do I pass the instance | name | in the creation of the instance? If I have the statement in Bar.py | "self.myInstance = Foo(). | Thanks. | Wayne I'm not sure if I completely understand your goals and your design. Also, I think you mixed up modules and classes in your description above. I just read the docs for java.awt.Component.enableEvents( long ) and noticed the following : This method only needs to be invoked by subclasses of Component which desire to have the specified event types delivered to processEvent regardless of whether or not a listener is registered. Are you trying to create a subclass of Component that needs to receive events even if no listeners are registered? Could you post some code showing what it is you are currently trying to do? If you have a class Foo that inherits from component, you could do something like the following, but I'm not sure if it is what you are looking for. ---- in some .py file ------ import java class Foo( java.awt.Component ) : def __init__( self ) : # note that 'self' now refers the the instance of 'Foo' and # therefore is-a instance of 'Component' self.enableEvents( java.awt.AWTEvent.WINDOW_EVENT_MASK ) def processEvent( self , event ) : """ @sig protected void processEvent( java.awt.AWTEvent event ) this method must be defined or you will end up with errors when the event dispatcher tries to call it """ print "Found an event!" print event HTH, -D |