How do an applet's support classes access necessary data files?

For example, suppose I have an applet MyApplet that uses a class
MyTableGUI which in turn requires loading up some GIF files.  AFAIK,
this requires that MyTableGUI know the document base for MyApplet
(please correct me if I'm wrong!).

If this is the case, I would have hoped that MyTableGUI would have had
recourse to some static method, e.g. Applet.staticGetDocumentBase(),
so that the required data could be loaded with:

  ImageIcon myIcon =
    new ImageIcon(new URL(Applet.staticGetDocumentBase(),
                          MY_ICON_FILENAME));


Or at least some static method (something like Applet.getInstance())
that returned the applet they were running under:

  ImageIcon myIcon =
    new ImageIcon(new URL(Applet.getInstance().getDocumentBase(),
                          MY_ICON_FILENAME));

But, AFAIK, no such methods exist, which means that MyTableGUI needs
to keep a reference to the instance of MyApplet it belongs to:

  ImageIcon myIcon =
    new ImageIcon(new URL(myAppletInstance.getDocumentBase(),
                          MY_ICON_FILE));

It seems to me extremely inelegant for every instance of an applet's
support class to have to keep a reference to the applet in order to
access global information such as the document base.  Is this the only
way around this problem?

Thanks,

KJ
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to