How to compile Java with icons

0

Previously, posted a question about how to compile my project in "Runnable Jar "with icons. And be able to do this with label and buttons. Now my question is how to do this in iconImage . I've tried the following:

setIconImage(Toolkit.getDefaultToolkit().getImage("D:\Utilitários\Desenvolvimento\Eclipse JEE Kepler SR2 (x64)\- Projetos\Pizzaria\src\Icones\fatcow-hosting-extra-icons-2\16\pizza.png"));

But it did not work, could anyone help me?

    
asked by anonymous 09.06.2014 / 15:52

1 answer

3
  • Your images should be in a folder of the exe source package: src / images / img.png
  • Following step 1, when generating the .jar of the app will not need external folder;
  • Follow the code below:

    URL imageURL = getClass().getResource("/images/confirmar.png");
    ImageIcon imageIcon = new ImageIcon(imageURL);
    frame.setIconImage(imageIcon.getImage());
    
  • Hope you can help.

        
    11.06.2014 / 23:39