Estou a tentar mudar a imagem de fundo do meu JFrame, mas estou a ter dificuldades. Aqui esta o código:
public class teste_tamagotchi extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
final Image backgroundImage = javax.imageio.ImageIO.read(new File("C:\\Bibliotecas\\Imagens\\galaxy-wallpaper-11.jpg"));
setContentPane(new JPanel(new BorderLayout()) {
@Override public void paintComponent(Graphics g) {
g.drawImage(backgroundImage, 0, 0, null);
}
});
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
E tenho o seguinte erro:
Cannot make a static reference to the non-static method setContentPane(Container) from the type JFrame