I take it your asking for help on the entire applet not just the switching images part. If so, try going through the tutorials on this site so you understand the construction of an applet.
As for the actual image switching bit you need something like this in your applet...
import java.awt.*;
import java.applet.*;
public class MyApplet extends Applet {
Image img1;
Image img2;
Image shownImage;
public void init() {
// Load in the images
img1 = Toolkit.getDefaultToolkit().getImage(...URL of image...);
img2 = Toolkit.getDefaultToolkit().getImage(...URL of second image...);
try {
// Wait for the images to be loaded
MediaTracker imgTracker = new MediaTracker(this);
imgTracker.addImage(img1, 0);
imgTracker.addImage(img2, 0);
imgTracker.waitForID(0);
} catch (Exception e) {
}
shownImage = img1;
}
public void paint(Graphics g) {
// Draws the currentl selected image
g.drawImage(shownImage, 0, 0, this);
}
// Method which does the image switching
public void methodTriggeredBySomeEvent(Event e) {
if(shownImage==img1) {
shownImage = img2;
} else {
shownImage = img1;
}
}
}
I havn't tested this and its not complete. You will have to put in the code which triggers the image switching bit.
Rob.
So *that's* what he meant...
Do note that it would be a lot better to load the images in a separate thread. The mediatracker will block init until all the images have been loaded, displaying a dead, grey rectangle to the user who is left wondering if the applet is still loading or does it work at all.