Java Image Load readImageToLabel(String netUrl)

Here you can find the source of readImageToLabel(String netUrl)

Description

read Image To Label

License

Apache License

Declaration

public static void readImageToLabel(String netUrl) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Image;

import java.io.IOException;

import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main {
    public static void readImageToLabel(String netUrl) {
        Image image = null;/*from  w  ww  .j  av a 2  s .  c  om*/
        try {
            URL url = new URL(netUrl);

            image = ImageIO.read(url);
        } catch (IOException localIOException) {
        }
        JFrame frame = new JFrame();
        JLabel label = new JLabel(new ImageIcon(image));
        frame.getContentPane().add(label, "Center");
        frame.pack();
        frame.setVisible(true);

        frame.setDefaultCloseOperation(3);
    }
}

Related

  1. loadImage(Object parent, String pathToImage)
  2. loadImage(String filename)
  3. loadImage(String filePath, int imageSize)
  4. loadImage(URL url)
  5. readImage(InputStream inp)