Coloco uma imagem no JFrame e para de compilar

Eu compilo o código da “BUILD SUCESS” e não aparece a tela e eu retiro a imagem e volta a funcionar

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
	at br.com.unissales.TesteTrabalho.visao.FrmTelaPrincipal.initComponents(FrmTelaPrincipal.java:94)
	at br.com.unissales.TesteTrabalho.visao.FrmTelaPrincipal.<init>(FrmTelaPrincipal.java:21)
	at br.com.unissales.TesteTrabalho.visao.FrmTelaPrincipal$6.run(FrmTelaPrincipal.java:186)
	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 SUCCESS

provavelmente o path está errado, mostra o codigo e tambem o caminho dessa img ai

1 curtida

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package br.com.unissales.TesteTrabalho.visao;

import java.awt.Toolkit;

/**
*

  • @author Gamer
    */
    public class FrmTelaPrincipal extends javax.swing.JFrame {

    /**

    • Creates new form FrmTelaPrincipal
      */
      public FrmTelaPrincipal() {
      initComponents();
      setIcon();
      }

    /**

    • This method is called from within the constructor to initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is always

    • regenerated by the Form Editor.
      */
      @SuppressWarnings(“unchecked”)
      //
      private void initComponents() {

      jButton1 = new javax.swing.JButton();
      jButton2 = new javax.swing.JButton();
      jButton4 = new javax.swing.JButton();
      jButton3 = new javax.swing.JButton();
      jLabel1 = new javax.swing.JLabel();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      setTitle(“ADM”);
      setBackground(new java.awt.Color(203, 202, 199));

      jButton1.setBackground(new java.awt.Color(52, 175, 35));
      jButton1.setFont(new java.awt.Font(“Tahoma”, 1, 12)); // NOI18N
      jButton1.setText(" Cadastro de Clientes");
      jButton1.setToolTipText("");
      jButton1.setBorderPainted(false);
      jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
      jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseClicked(java.awt.event.MouseEvent evt) {
      jButton1MouseClicked(evt);
      }
      });
      jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButton1ActionPerformed(evt);
      }
      });

      jButton2.setBackground(new java.awt.Color(52, 175, 35));
      jButton2.setFont(new java.awt.Font(“Tahoma”, 1, 12)); // NOI18N
      jButton2.setText(“Cadastro de Produtos”);
      jButton2.setBorderPainted(false);
      jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
      jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButton2ActionPerformed(evt);
      }
      });

      jButton4.setBackground(new java.awt.Color(52, 175, 35));
      jButton4.setFont(new java.awt.Font(“Tahoma”, 1, 12)); // NOI18N
      jButton4.setText(" Pedidos");
      jButton4.setToolTipText("");
      jButton4.setBorderPainted(false);
      jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
      jButton4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButton4ActionPerformed(evt);
      }
      });

      jButton3.setBackground(new java.awt.Color(52, 175, 35));
      jButton3.setFont(new java.awt.Font(“Tahoma”, 1, 12)); // NOI18N
      jButton3.setText(“Gestão de Funcionários”);
      jButton3.setBorderPainted(false);
      jButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButton3ActionPerformed(evt);
      }
      });

      jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/unissales/TesteTrabalho/visao/icon/logo_green_food.png"))); // NOI18N

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE))
      .addContainerGap())
      .addGroup(layout.createSequentialGroup()
      .addGap(148, 148, 148)
      .addComponent(jLabel1)
      .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap()
      .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
      .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addComponent(jLabel1)
      .addContainerGap())
      );

      layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton1, jButton2, jButton4});

      pack();
      setLocationRelativeTo(null);
      }//

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    new FrmClientes((this), true).setVisible(true);
    }

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    new FrmProdutos((this), true).setVisible(true);
    }

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
    new FrmPedidos((this), true).setVisible(true);
    }

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

     new FrmFuncionarios((this), true).setVisible(true);
    

    }

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    }

    /**

    • @param args the command line arguments
      /
      public static void main(String args[]) {
      /
      Set the Nimbus look and feel /
      //
      /
      If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

      • For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
        */
        try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if (“Nimbus”.equals(info.getName())) {
        javax.swing.UIManager.setLookAndFeel(info.getClassName());
        break;
        }
        }
        } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(FrmTelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(FrmTelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(FrmTelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(FrmTelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //

      /* Create and display the form */
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      new FrmTelaPrincipal().setVisible(true);
      }
      });
      }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration

    private void setIcon() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource(“icon.png”)));
    }
    }

o caminho da imagem ta automatico: /br/com/unissales/TesteTrabalho/visao/icon/logo_green_food.png