How to compile Java with icons

Asked

Viewed 155 times

0

Formerly, post a question of how to compile my project in "Runnable Jar" with icons. And manage to do this with label and Buttons. Now my doubt is how to do this in iconImage. I 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 didn’t work, someone could help me?

1 answer

3


  1. Your images must be in an exe font package folder.: src/images/img.png
  2. Following step 1, when generating the app . jar you will not need external folder;
  3. Follows code:

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

I hope it helps you.

Browser other questions tagged

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