I newly started programming java and am currently trying to figure out how to draw images. I get an error that tells me I am doing something wrong even though I am only doing what I learned on the oracle tutorials.
My error appears when I try to compile it with "cmd.exe". The error in detail is like this:
Pictures.java:18: error: cannot find symbol
} catch (IOExeption e) {
^
symbol: class IOExeption
location: class Pictures
Pictures.java:27: error: cannot find symbol
g.drawImage(img, 50, 50, null);
^
symbol: variable img
location: class Pictures
2 errors
And this is my java code:
import javax.imageio.*;
import java.io.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.*;
public class Pictures {
static JFrame Frame = new JFrame("Pictures");
public static void main(String[] args) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("Blacksquare.jpg"));
} catch (IOExeption e) {
}
Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Frame.setSize(400, 400);
Frame.setVisible(true);
}
public void paint(Graphics g) {
g.drawImage(img, 50, 50, null);
}
}