I want to display an image in my Java application. I found a code to download the image from the webserver and show it in the jframe.
I want to use a label to show the image or something else. It shouldn't be JFrame.
Here is my code:
Image image = null;
try {
URL url = new URL(
"http://www.personal.psu.edu/acr117/blogs/audrey/images/image-2.jpg");
image = ImageIO.read(url);
} catch (IOException e) {
}
// Use a label to display the image
JFrame frame = new JFrame();
JLabel lblimage = new JLabel(new ImageIcon(image));
frame.getContentPane().add(lblimage, BorderLayout.CENTER);
frame.setSize(300, 400);
frame.setVisible(true);
Can someone help me?