A
Arne Styve
Hi,
I'm building an application where I want to use buttons (JButton) with
images loaded from files (.GIF-files).
At the moment, I create the ImageIcon's to use like this:
disconIcon = new ImageIcon("resources/images/discon.gif");
lightOnIcon = new ImageIcon("resources/images/LightOn.gif");
lightOffIcon = new ImageIcon("resources/images/LightOff.gif");
and then use the setIcon()-method of the button to set the Icon.
This works, but I'm not quite confortable with it.
What is the best strategy for placing image-files so that they will always
be found, both when running the application from within Eclipse, and when
creating a JAR of the application for distribution ? When creating a JAR, I
would like the image-files to be packed within the JAR. How should I refere
to the image-files to ensure they will always be found independent of where
my code/JAR-file is installed on the target ?
Regards
Arne
I'm building an application where I want to use buttons (JButton) with
images loaded from files (.GIF-files).
At the moment, I create the ImageIcon's to use like this:
disconIcon = new ImageIcon("resources/images/discon.gif");
lightOnIcon = new ImageIcon("resources/images/LightOn.gif");
lightOffIcon = new ImageIcon("resources/images/LightOff.gif");
and then use the setIcon()-method of the button to set the Icon.
This works, but I'm not quite confortable with it.
What is the best strategy for placing image-files so that they will always
be found, both when running the application from within Eclipse, and when
creating a JAR of the application for distribution ? When creating a JAR, I
would like the image-files to be packed within the JAR. How should I refere
to the image-files to ensure they will always be found independent of where
my code/JAR-file is installed on the target ?
Regards
Arne