阅读后https://www.instagram.com/developer/embedding/#media_redirect ,我想知道是否可以使用该图片作为 SWING 的 ImageIcon ?
最佳答案
如果链接提供了有效的图像,那么您可以将其用作图像图标。以下代码有助于实现您想要的目标
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String fullUrlPath = "your image path";
try {
URL url = new URL(fullUrlPath);
BufferedImage img = ImageIO.read(url);
ImageIcon icon = new ImageIcon(img);
JOptionPane.showMessageDialog(null, icon);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
关于java - 在 Java Swing 中使用 Instagram 图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40190925/