I have a quick question about Java. I apologize if this question is really basic, but I'm a beginner Java programmer: D
I want to make a 2d image in a window, but I cannot figure it out. I looked at the graphical API here:
http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html
and the only way I could find could work: drawImage (). However, this did not work for me, but maybe this is due to the ImageObserver Observer parameter? I just put null for this, following some tutorial that I found somewhere, but I still have a compilation error: Here is my drawing method:
public void paint(Graphics g) { Image img1 = Toolkit.getDefaultToolkit().getImage("theImage.png"); g.drawImage(img1, 100, 100, null); }
and here are the methods that call it:
public static void main(String[] args) { MyGame game = new MyGame(); game.setVisible(true); game.play(); }
The fact is, when I call paint in a while loop, I get this error: paint (java.awt.Graphics) in MyGame cannot be applied to ()
What does it mean? How can I fix this so that I can successfully display a 2d image?
Thanks in advance: D
Steve source share