The variable was made, the image is loaded into the variable and the paintComponent is asked to display the image in my JPanel. I can't see my mistake.
public class Main extends JFrame {
public static void main(String[] args) {
JFrame frame = new Main();
frame.setSize(1524, 715);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Animatieproject Stijn Mannaerts: Free Kick");
frame.setContentPane(new Voetbalveld());
frame.setVisible(true);
frame.setLocationRelativeTo(null);
}
}
class Voetbalveld extends JPanel {
private ImageIcon afbIntro;
public Voetbalveld() {
afbIntro = new ImageIcon("scr/afbeeldingen/Intro.jpg");
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
afbIntro.paintIcon(null, g, 0, 0);
}
}