简体   繁体   中英

Add image from URL in jPanel

I have a small problem, I have tried different solutions to add a image from URL in my jPanel, but I don't succeed. This is how my jPanel looks like:

import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;


public class Hello extends JPanel{

    JPanel panel = new BackgroundPanel();
    JPanel HomeWindowPanel;
    JLabel secondlbl = new JLabel("Hello");

    public Hello () {
        //I want to add a picture here from URL
    }
}

I would really appreciate if somebody could show me how to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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