Hi

I think that you can use Applet.getCodeBase(), which will return a URL for
the location of the applet. Then, you can add the rest of the URL onto that
and use Applet.getImage(). For example:

URL u = new URL(getCodeBase() + "/img.jpg");

You can only call this from applet methods such as init(). The trick here is
to have a global URL variable. If you run as an applet, use the above line
of code to place the correct URL into your global variable. If you are
running it as an application, you should also assign the URL in a method
that isn't called by the applet, i.e. the main() method. When you are ready
to actually retrieve your image(maybe in a getTexture() method), you use the
global URL.

B.D.

>From: Nathan Bower <[EMAIL PROTECTED]>
>Reply-To: Discussion list for Java 3D API <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: [JAVA3D] appletizing
>Date: Fri, 6 Jul 2001 21:22:15 +0100
>
>Hello guys, and gals,
>
>An appletizing problem (yum) for you here.
>
>Ive been turning my java3d standalone program into an applet for erm about
>a week now. Ive had a few tricky problems and this one I think somone else
>would have experienced before.
>
>In accessing a file (.jpg texture) I am using FILE and a string which
>consists of
>String filename = String.valueOf(tile.toExternalForm ());  // + more path &
>filename info.
>This results in trying to access a file from a location such as
>http://www.bhaldebla.com/images/1.jpg
>
>However - it dosent work.
>
>Q1. Has anyone else had a similar problem to this?
>Q2. What (generally) would be the method of accessing required data files
>from applets - retaining the ability to run as stand alone!
>
>
>Thanking you,
>
>Nathan
>
>
>PS. ARgggg!
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to