nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Retrieve image file from data folder #360

Closed jiaqi20 closed 4 years ago

jiaqi20 commented 4 years ago

Does anyone know how to get image files (the right image file path to use) from the data folder? I was able to write the images that were downloaded using URL into the local data folder which has the same directory as jar file but couldn't retrieve them to display in the application.

I tried using ("data/" + filename) as the image path but doesn't seem to work.

GeNiaaz commented 4 years ago

Does it just not show up in the IntelliJ view window? Because that happens sometimes. You should test out by checking it out on Github itself to view it there.

jiaqi20 commented 4 years ago

Ohh thanks for your reply! but I meant like how to get the correct image filepath (files in data folder) to parse and create an Image(filepath) object so that I can do imageView.setImage(Image) to display in the application for jar file testing :'(

WM71811 commented 4 years ago

I am not sure if my interpretation is correct, but if you would like to put the image in GUI, maybe you can move it to resources/images?

damithc commented 4 years ago

I assume this issue has been resolved. Feel free to reopen if not.

jiaqi20 commented 4 years ago

Yes. I solved the issue by adding these paths to the original image path then it works. Thanks everyone for the help!

  1. "file://"
  2. Using this.getClass().getProtectionDomain().getCodeSource().getLocation(); to get the location of folder where user saves the jar file