0 Replies - 812 Views - Last Post: 12 February 2010 - 11:33 AM Rate Topic: -----

#1 Jude Nash  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 98
  • Joined: 25-October 08

Put Image In Applet

Posted 12 February 2010 - 11:33 AM

Hello fellow programmers,
I am creating an imageTokenizer class for a side-scrolling video game. However, I am running into some problems putting images in an applet. This loads fine but doesn't show me the image. Any advice would be helpful.

Thanks,
Jude Nash
import java.applet.Applet;
import java.awt.*;
 
public class imagePractice extends Applet
{
	private Image img;
 
	public void init()
	{
		img = null;
	}
 
	public void loadImage()
	{
		try
		{
			img = getImage(getCodeBase(), "image.jpg");
			System.out.println(img);
			System.out.println(prepareImage(img, 300, 400, this));
		}
		catch(Exception e){}
	}
 
	public void paint(Graphics g)
	{
		if (img == null)
			loadImage();
		g.drawImage(img, 0, 0, this);
	}
}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1