简体   繁体   English

在Java Swing中使用Instagram图片

[英]Use Instagram Picture in Java Swing

在阅读https://www.instagram.com/developer/embedding/#media_redirect之后 ,我想知道是否可以将图片用作SWING的ImageIcon?

if the link provides a valid image then you can use it as image icon. 如果链接提供了有效的图像,则可以将其用作图像图标。 following code can be useful in achieving in what you want 以下代码可以帮助您实现所需的目标

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();
               }                 
         }
      });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM