Reputation: 113
How to set the images in background of shell using relative path. I have image which resides in folder "res". I am adding screen shot here, just you to have better understanding of 'directory structure' as well as my question(in case if it seemed little ambiguous to you). Any suggestion and help will be appreciated.
Upvotes: 1
Views: 2216
Reputation: 9946
In order to read your images from resources
folder, you need to :
add res folder to classpath
locate file absolutely, i.e. "/res/SplashWindow.jpg"
Hope this helps
Upvotes: 1
Reputation: 417642
The SplashWindow.jpg
is placed next to the class notDltNow
which you specify as the reference for relative paths, so you can simply write:
shell.setBackgroundImage(SWTResourceManager.getImage(
notDltNow.class, "SplashWindow.jpg"));
It is also a good idea to put resources inside the src
folder so when you export your code e.g. into a jar, the resources will also be exported and still available to the code without additional hassle.
Upvotes: 2