From: D-Man <ds...@ri...> - 2001-03-28 15:57:03
|
In Java everything is coded as part of a class. As an example class take this : public class Foo { public void func1( ) { System.out.println( "Hello from func1" ) ; } static public void func2( ) { System.out.println( "Hello from func1" ) ; } } This class contains 2 methods, func1 and func2. func2 is declared as static. That means that the following (Java) code is legal : Foo.func2() ; Foo f = new Foo() ; f.func2() f.func1() while the following is illegal : Foo.func1() ; The reason is that only "static" members belong to the _class_, all others belong to _instances_ of the class. In order to call the method you must first have an instance of java.awt.Component and call it on the instance. Note also that it will only affect the instance you call it on, not all instances of the class. Python's classes don't have any "static" members because Python doesn't force you to write everything inside of a class construct. Instead put "static" functions in the module. (If you are trying to use a mix of Java and Python then the java code is unable to access module level stuff unless it goes through the interpreter directly) -D On Wed, Mar 28, 2001 at 06:37:53PM -0500, cindy wrote: | Thanks for your reply, I also made it a bookmark. | I went to the site and track down enableEvents() and | found that it was a method of Component. So I imported | java.awt.Component and then qualified enableEvents with | java.awt.Component. I get an error tell me that enableEvents() | is not an attribute of Component. So I checked my spelling | ant thing look ok. Can someone tell me what I doing wrong? | Thanks. | Wayne |