Boa noite, estou tentando inserir uma imagem como plano de fundo em um JFrame, porém encontro esse erro “Exception in thread “main” java.lang.NullPointerException”.
obs: Aceito novas ideias para inserção de imagem.
package View;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Menu {
JFrame janela = new JFrame ("MENU");
JLabel aux = new JLabel ();
ImageIcon planoFundo = new ImageIcon (getClass().getResource("fundo.png"));
public Menu ()
{
janela.setSize(905,700);
janela.setDefaultCloseOperation(janela.EXIT_ON_CLOSE);
janela.setLocationRelativeTo(null);
aux.setIcon(planoFundo);
janela.add(aux);
janela.setVisible(true);
}
public static void main (String[] args)
{
Menu menuInicial = new Menu ();
}
}

