When running this program I get this error code thrown back:
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at DebugMe.<init>(DebugMe.java:16)
at DebugMe.main(DebugMe.java:31)
However no errors are being thrown within the compiler itself. The "debug.jpeg" image is within the same folder that the program is being run from as well.
import java.awt.*;
import javax.swing.*;
public class DebugMe extends JFrame
{
private String message = "Congratulations, the program is working again.";
Image debug = new ImageIcon(this.getClass().getResource("debug.jpeg")).getImage();
int x; //Initialized x
/**
* Constructor for objects of class DebugMe
*/
public DebugMe()
{
x = 0;
setSize(500, 500);
setVisible(true); //Lowercase t on true
}
public static void main(String[] args)
{
DebugMe myDebugMe = new DebugMe(); //capitalized me in Debugme
int x;
}
public void paint(Graphics g)
{
super.paint(g);
g.drawString("message", 100, 100);
g.drawImage(debug, 100, 200, Color.BLUE, this);
}
}