Skip to content

Instantly share code, notes, and snippets.

@uditveerwani
Created November 13, 2011 12:35
Show Gist options
  • Save uditveerwani/1362064 to your computer and use it in GitHub Desktop.
Save uditveerwani/1362064 to your computer and use it in GitHub Desktop.
Loading images in applet
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ImageTest extends Applet {
Image src;
public void init(){
setSize(700,600);
try {
src = ImageIO.read(new File("C:\\sumthing.jpg"));
}catch(FileNotFoundException fe){
fe.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
public void paint(Graphics g){
g.drawImage(src, 10, 10,this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment