I have an image I want to be painted as the backgroudn image of a JPanel, but the paintComponent method is not being called. Here's my class:
package com.cyledawson.tworeborn;
import java.awt.*;
import javax.swing.*;
public class BackgroundImage extends JPanel {
private static final long serialVersionUID = 1L;
public BackgroundImage() {
super();
setPreferredSize(new Dimension(800, 600));
repaint(); //Added to see if paintComponent is even being launched. It's not
}
public void paintComponent(Graphics g) {
JOptionPane.showMessageDialog(null, "Rawr");
g.drawImage(new ImageIcon("terra_client_image.png").getImage(), 0, 0, 800, 600, this);
super.paintComponents(g);
}
}
Two notes: 1) I added a JOptionPane to check is paintComponent is being launched, and the message pane doesn't appear, and 2) As I noted, I decided to add a repaint() to the constructor in hopes it would launch the paintComponent method, but it did not.
I'm sure there's just some small mistake I'm completely overlooking, but I can find it.