From: D-Man <ds...@ri...> - 2001-04-04 15:06:11
|
On Wed, Apr 04, 2001 at 11:01:51PM -0400, cindy wrote: | > The following code worked for me : | > | > from java.awt import Component , AWTEvent | > | > class C( Component ) : | > def __init__( self ) : | > self.super__enableEvents( AWTEvent.WINDOW_EVENT_MASK ) | | Ok. So this means that ever time I wanted to use this method, "enableEvents()" I | have to | inherit Component. But lets say that I would like to extend some other | component, like | JFrame. Then if I want to use enableEvents() in the same class that I want to | extend | JFrame, I would have to inherit Componet and do a composit on JFrame. Is this | correct? Not quite. If you look at the top of the documenation for JFrame you will see Class JFrame java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--java.awt.Frame | +--javax.swing.JFrame JFrame already inherits from java.awt.Component. The term "is-a" is often used with inheritance. A JFrame object is-a Component object. If you inherit from JFrame, you are indirectly inheriting from Component. If you look farther down on the documentation page you will see a list of "Methods inherited from Frame" and "Methods inherited from Window" and ... and "Methods inherited from Component". Since the methods are listed there, they exist in objects of the type "JFrame". FYI, the documentation (for JDK1.2.2) is at http://java.sun.com/products/jdk/1.2/docs/api/index.html while the JFrame page is http://java.sun.com/products/jdk/1.2/docs/api/javax/swing/JFrame.html -D |