Things to consider, (if your image files are embedded resources, and not dependent on your file system)
How will you store the image paths? You can simple just store the file names
image.png
What complete file path will you ultimately use. Have a set path (excluding the image file name), and based off your application file structure that is the path you will use, concatenated with with image file name. Example
ProjectRoot src resources images image.png private static final String PATH = "/resources/images/";
How will you load the image. You should read the image from the class path, using
getClass().getResource()
and you can just load the images to anImageIcon
and eventually adding them toJLabel
. ExampleString location = rs.getString("Location"); Image image = ImageIO.read(getClass().getResource(PATH + location)); ImageIcon icon = new ImageIcon(image); JLabel label = new JLabel(icon); // add label to something.