I am trying to retrieve an Image from the web and then put in to a Image view in Java FX. How ever I am getting a mismatch error of Unresolved compilation problem: Type mismatch: cannot convert from Buffered Image to Image. How can I retrieve the Image on from the web then display it on to my Application.
My Code
URL url2 = new URL("http://mars.jpl.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/01004/opgs/edr/fcam/FLB_486615455EDR_F0481570FHAZ00323M_.JPG");
Image image = ImageIO.read(url2);
imageV.setImage(image);
CodePudding user response:
Don’t try to convert the image using swing and imageio. Also don’t create a URL object. None of that is unnecessary.
Just load the image directly from the url string using the image constructor.