Created
November 13, 2011 12:35
-
-
Save uditveerwani/1362064 to your computer and use it in GitHub Desktop.
Loading images in applet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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