Does anyone know how to display an image from a file on your screen?
I am making a game and am tired of jsut using shapes such as rectangles and other things. Does anyone know how to put in your own files as images onto a JFrame? If you do then please teach me how to set it up and what parameters it takes and other things I need to know about it. Here is what I have done so far but it didn't work.
Code :
package galaga;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ImageObserver;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class HELPME extends JFrame {
ImageIcon worthless = new ImageIcon("CRAPPYSPACESHIP.png");
Image SHIP = worthless.getImage();
JFrame HELPME = new JFrame();
JPanel bob = new JPanel();
public HELPME() {
super("Title");
setVisible(true);
setSize(400, 400);
}
public void paint(Graphics g) {
g.drawImage(SHIP, 100, 200, 50, 90, ImageObserver );
}
}
I wrote ImageObserver because I don't know what it is. If anyone tries to help me it will be much appreciated!
Re: Does anyone know how to display an image from a file on your screen?
Re: Does anyone know how to display an image from a file on your screen?
No this is just displaying an image the other one is makeing it move and displaying it