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.
Check out this sample code:
Specifically the createImageIcon method.
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.