//file: MyApplet.java
import java.net.*;
import java.awt.Image;
public class MyApplet extends javax.swing.JApplet {
public void init( ) {
try {
// absolute URL
URL monaURL =
new URL( "http://myserver/images/mona_lisa.gif");
Image monaImage = getImage( monaURL );
// applet resource URL
URL daffyURL =
getClass( ).getResource("cartoons/images/daffy.gif");
Image daffyDuckImage = getImage( daffyURL );
}
catch ( MalformedURLException e ) {
// unintelligable url
}
}
// ...
}
|