how to display images in java?

Vincent J

New member
im trying to make a little game in java, and in order to do that i need to be able to display images in specific spots on the screen.

here is an example online that is usless to me

import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;

public class LoadAndShow extends JPanel
{
BufferedImage image;

public LoadAndShow(BufferedImage image) {
this.image = image;
}

protected void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, this);
}

}


it works, but it is usless for making a game. I need to be able to call one function that accepts an image, and its location, and places the top left corner of the image at that location. How can i do that?
 
Back
Top