Jeff_UK is right about input being used uninitialized, but the call to add should succeed: If a function is called without an object on which it should be called, the object this is assumed - and this is Class distance which is a child of Applet which is a child of Panel which is a child of Container, which has add().
And the error SkyHi is getting is no compiler error, it is a runtime error: A standalone Java program is required to have a method
public static void main(String[] args)
as entry point. An applet is no standalone program, but is required to have certain other functions, namely init, start, stop and destroy - the only problem is that the IDE SkyHi is using doesn't recognize the program as an applet and seeks for the main() entry point - in vain. And the Java runtime engine can't spit out a line number of a source code it fails to find... ;) |