Packaging in java [duplicated]

0

What happens is that I'm doing a project for my university and I have the following problem:

  • The university requires me to do the packaging of my program but in doing so it happens, it does not show any type of image, I am using the following function which is:

    ImageIcon imagen = new ImageIcon("src/imagenes/descarga.png");
    Icon icono = new ImageIcon(imagen.getImage().getScaledInstance(lblfondo.getWidth(), lblfondo.getHeight(), Image.SCALE_DEFAULT));
    lblfondo.setIcon(icono);
    
  • I would like to know if any of you could give me a solution to this problem, thank you.

    the program when running it in java comes out like this:

        
    asked by jose gregorio lobo mattar 16.03.2018 в 19:01
    source

    1 answer

    0

    You have to use:

    ImageIcon icon = new ImageIcon(getClass().getResource("/src/imagenes/descarga.png"));
    
        
    answered by 17.03.2018 в 11:57