how to display a image in java application

Posted by Nubkadiya on Stack Overflow See other posts from Stack Overflow or by Nubkadiya
Published on 2010-05-31T13:03:20Z Indexed on 2010/05/31 13:13 UTC
Read the original article Hit count: 271

Filed under:
|
|

i want to display a image in my java application. i found a code to download the image from the webserver. what that code do is it takes the image and show it in the jframe.

i want to use a label to show the image or soemthing else. so i can put it in my java application. can someone help me. it shouldnt be JFrame

please help me

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

© Stack Overflow or respective owner

Related posts about java

Related posts about image