Error Inserting icon in Jmenu

Asked

Viewed 12 times

-1

Good Morning to all,

I’m with a java project using Netbeans IDE 12.0, when trying to insert images as icon in the Item Menu and running the form introduces me to Exception nullpointerexception, below is how the form designer is doing

inserir a descrição da imagem aqui

And below is the error that occurs:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
    at view.FrmTelaInicial.initComponents(FrmTelaInicial.java:90)
    at view.FrmTelaInicial.<init>(FrmTelaInicial.java:22)
    at view.FrmTelaInicial$3.run(FrmTelaInicial.java:220)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
BUILD SUCCESSFUL (total time: 4 seconds)

Below is the line of automatically generated IDE error code at view.FrmTelaInitil.initComponents(Frmtelainitial.java:90) that I believe is the cause of my problems.

jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/clientes.png"))); // NOI18N

I am more beginner as I could notice by analyzing the error is that, maybe the image of the icon is not being found even indicating the path to instantiation of Imageicon. And that when you compile the form the Imageicon is null and generating the Exception.

Follow print of the package where the image is:

inserir a descrição da imagem aqui

1 answer

0

With the help of my teacher of the course I managed to solve the problem by clicking on Clear and Builder. Doing this did not give more error.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.