
For example your project name is Your Project then expand the Source Package Tree
you will see a pakage named as yourproject.resources expand it too as in image below
now Expand YourProjectApp.properties and right click on YourProjectApp.properties as shown below
and go to add and click to property as shown in picture
This dialog will appear
now fill key as per your choice for ex: hutch
and value is the file name you going to add ex.”hutch.png”
now go to physically your project resources folder for ex.
“F:\Your Project\src\yourproject\resources” and paste the image file you want to add..
now add a jbutton and jlabel on the jframe or jpanel…on jbutton actionperfomed put this code
org.jdesktop.application.ResourceMap rMap =
org.jdesktop.application.Application.getInstance(yourproject.YourProjectApp.class).getContext()
getResourceMap(YourProjectAboutBox.class);
jLabel1.setIcon(rMap.getIcon("hutch"));Now Your Are all done click the button and see the output
Click below to launch the example
Download Full Source Code
Source Code
0 comments:
Post a Comment