0
閱讀https://www.instagram.com/developer/embedding/#media_redirect後,我想知道我是否可以將圖片用作SWING的ImageIcon?在Java Swing中使用Instagram圖片
閱讀https://www.instagram.com/developer/embedding/#media_redirect後,我想知道我是否可以將圖片用作SWING的ImageIcon?在Java Swing中使用Instagram圖片
如果鏈接提供了有效的圖片,則您可以使用作爲圖片圖標。下面的代碼可以在實現你想要什麼
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();
}
}
});
感謝您的評論 –
感謝您的評論 你的答案被清除了事情的一半有用的,另一半則是如何獲得鏈接的API是專爲JavaScript –
@GhassenTounsi你可以使用java包裝的api像jInstagram。或者你可以自己寫。 – Selim