JAR - imagens

1 resposta
ricardolecheta

Eu tenho uma pasta “icons” com algumas imagens que preciso carregar no meu aplicativo…

— teste.jar
— icons/

o aplicativo roda perfeitamente, mas como se faz para colocar esta pasta “icons” em um zip ou jar? tentei fazer isso mas parou de encontrar as imagens… :?:

obrigado a todos :smiley:

1 Resposta

M
The following code example shows how to retrieve images from a JAR file:

   // Get current classloader
   ClassLoader cl = this.getClass().getClassLoader();
   // Create icons
   Icon saveIcon  = new ImageIcon(cl.getResource("images/save.gif"));
   Icon cutIcon   = new ImageIcon(cl.getResource("images/cut.gif"));
   ...

The example assumes that the following entries exist in one of the JAR files for the application:

images/save.gif
images/cut.gif
Criado 4 de agosto de 2003
Ultima resposta 5 de ago. de 2003
Respostas 1
Participantes 2