I'm trying to set JButton ImageIcon with an image taken from a URL. This is the code I have:
try{
URL imageFile=new URL(picturePath);
carPic=ImageIO.read(imageFile);
picturePane.setIcon(new ImageIcon(carPic));//this line gives the exception
}catch(IOException e){
e.printStackTrace();
}
Where "picturePath" is the image URL.
The URLs I plan to use are just the normal ones obtained with "copy image address" and read as such: "https://www.topgear.com/sites/default/files/544822_0.jpg"
Do I have to do something to the URLs to get them to work right, or is there some other problem with the code itself?