Java Reference
In-Depth Information
image = getImage( new URL(
"fi le:///d:/Applet Stuff/"
+ "Pre-Swing/earth.gif") ) ;
Obviously, you will need to change the above
URL to match up to your local directory
structure if you wish to test the operation
of this applet.
catch (MalformedURLException muEx)
System.out.println("Invalid URL!");
public void paint(Graphics g)
This applet runs without problem in the appletviewer and the two browsers, but
only if both applet fi le and image fi le are in the same directory as the associated
HTML fi le. (Output is shown in Figs. 12.10 and 12.11 .) If the fi les are in different
directories, a security exception is generated. This would appear to make the use of
a path redundant, of course. Indeed, it turns out that using the string “fi le:///d:earth.
gif” works just as well as using the full path “fi le:///d:/Applet Stuff/Pre-Swing/earth.
Fig. 12.10 Output from
applet ImageTest1b under the
Search WWH ::

Custom Search