Tapas Bose
2010-07-21 09:07:27 UTC
Hello everybody.
I am learning Java Swing. At present JButton. I am trying to add an image with button in the function settingButton(). I am unable to run the .jar file with the supplied image. I made a folder namely "resource" under the Project folder "Button Change", same level with "build", "dist" and others. I then have added that "resource" folder with my Project by right clicking on the project name "Button Change" in Projects window->Then Properties->Adding folder "resource" by browsing, as the "Source Package Folders" under the categories "Sources" and saving the changes. Then I put "Button-Add.ico" file into that "resource" folder. And trying to access the file by code :
Code:
button.setIcon(new ImageIcon("C:/Users/Tanmoy/Documents/NetBeansProjects/Button Change/resource/Button-Add.ico"));
But I cannot able to display that icon. What I am doing wrong? It will be very helpful to me. Thank you.
I am learning Java Swing. At present JButton. I am trying to add an image with button in the function settingButton(). I am unable to run the .jar file with the supplied image. I made a folder namely "resource" under the Project folder "Button Change", same level with "build", "dist" and others. I then have added that "resource" folder with my Project by right clicking on the project name "Button Change" in Projects window->Then Properties->Adding folder "resource" by browsing, as the "Source Package Folders" under the categories "Sources" and saving the changes. Then I put "Button-Add.ico" file into that "resource" folder. And trying to access the file by code :
Code:
button.setIcon(new ImageIcon("C:/Users/Tanmoy/Documents/NetBeansProjects/Button Change/resource/Button-Add.ico"));
But I cannot able to display that icon. What I am doing wrong? It will be very helpful to me. Thank you.