Exception in thread "main" java.lang.NullPointerException at java.desktop/javax.swing.ImageIcon.(ImageIcon.java:217) at mystia1123.Receipt.(Receipt.java:17) at mystia1123.Receipt.main(Receipt.java:35)
package mystia1123;
import javax.swing.*;
import java.awt.*;
public class Receipt extends JFrame {
private JFrame frame;
private ImageIcon image;
private JLabel jLabel;
public Receipt(){
image=new ImageIcon(getClass().getResource("1.png"));
jLabel = new JLabel(image);
jLabel.setSize(650,450);
frame=new JFrame("Receipt");
frame.add(jLabel);
frame.setLayout(new FlowLayout());
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.pack();
}
public static void main(String[] args) {
new Receipt();
}
}