This has been confusing me for quite a long time now. The problem is that I want to display some images in a JFrame. I know how to do that, just use ImageIcon
. However, it requires a path to the image. So if I compiled the project into a jar and gave it to my friend, the image would not appear because the image file is not on my friend's device!
In Android Studio, the IDE takes care of these stuff. You just need to put the images into the drawable
folder and it generates the code for you. The same applies to Visual Studio. I just need to "Import" the images.
But I see nothing in Eclipse regarding image resources. How can I add images to the JFrame through an "Image resource" thingy?