[thelist] Using Java modules in another class in same program

Peter Barrett peterb at corel.com
Fri Mar 9 09:42:14 CST 2001


CDitty wrote:

> I have a java applet that loads the java.net.* module.  When I try and
> access this module from another class within the save program, I get a
> Can't find method "getDocumentBase()" error.
>
> How can I reference this module from within the  section below?
> class TriPeaksPlayArea extends Canvas {
>
> }

If I'm understanding this correctly.... you have imported java.net.* into
MyApplet.class, which uses the TriPeaksPlayArea class? Either you need to
import the java.net.* package into TriPeaksPlayArea, or you could write a
wrapper function in MyApplet

public URL wrapperForGetDocumentBase(){
    return getDocumentBase();
}

which you can call from other classes in the same package/project. I don't
know of any reason not to just import java.net.* into any other classes
that need it, though (since it will be using up memory in the JVM
anyway...).

hth,
~pete





More information about the thelist mailing list