hey all
when i run this code :
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.awt.image.BufferedImage;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.imageio.ImageIO;
public class SpaceInvaders {
public static final int WIDTH = 800;
public static final int HEIGHT = 600;
public SpaceInvaders() {
JFrame window = new JFrame("Invaders");
JPanel panel = (JPanel)window.getContentPane();
panel.setBounds(0,0,WIDTH,HEIGHT);
panel.setPreferredSize(new Dimension(WIDTH,HEIGHT));
panel.setLayout(null);
panel.add(this);
window.setBounds(0,0,WIDTH,HEIGHT);
window.setVisible(true);
window.addWindowListener(new WindowAdapter() {
public void WindowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public BufferedImage loadImage(String name) {
URL url = null;
try {
url = getClass().getClassLoader().getResource(name);
return ImageIO.read(url);
}
catch(Exception e) {
System.out.println("Cannot load image " + name + " in " + url);
System.exit(0);
return null;
}
}
public void paint(Graphics g) {
BufferedImage bicho = loadImage("res\bicho.gif");
g.drawImage(bicho, 40,40,this);
}
public static void main(String[] args) {
SpaceInvaders inv = new SpaceInvaders();
}
}
i get a problems with panel.add(this)
and g.drawImage(bicho,40,40,this)
anyone know why?? It says cannot resolve symbol...
ps bout the decytption thing... gonna leave it for the mo till i get more exp.