Welcome to Java Examples

Take a cup of tea and Let's Start programming


I have written this program to understand how to add images into applet using imageTracker...getImage is used to get location off that image...you can set height and width of image when you are drawing that image to applet.. let's see an example...



//dance floor import java.applet.*; import java.awt.*; /**@author jaimin shah **/ public class dance_floor extends Applet{ Image img,img1,img3; MediaTracker tr; public void paint(Graphics g) { tr = new MediaTracker(this); img = getImage(getCodeBase(), "dance_floor.jpg"); tr.addImage(img,0); g.drawImage(img, 0, 0,500,500, this); img1 = getImage(getCodeBase(), "dance_1.gif"); tr.addImage(img1,0); g.drawImage(img1, 100, 200,150,200,this); img3 = getImage(getCodeBase(), "dance_3.gif"); tr.addImage(img3,0); g.drawImage(img3, 250, 220,150,200,this); } }


Output

0 comments :

Post a Comment