I have a Java Swing App, And I'm using an API, that API has all of the countries, their names and images. The images are in .SVG format. So I'm using FlatLaf libraries to show SVG images. I created a class named SVGImage.java and it is for adding an icon to JLabel, the code:
import com.formdev.flatlaf.extras.FlatSVGIcon;
import javax.swing.JLabel;
public class SVGImage extends JLabel {
private FlatSVGIcon svgIcon;
public void setSvgImage(String image, int width, int height) {
svgIcon = new FlatSVGIcon(image, width, height);
setIcon(svgIcon);
}
}
I'm using this in my MainJFrame
class like this:
sVGImage1.setSvgImage("https://media.api-sports.io/flags/gb.svg", 300, 300);
This works fine with local SVG images, but when I try to open a URL like in this example, it can't display the image. What should I do? How can I display the SVG images from an URL? Thank you.