How to add a picture from internet in my application

Posted on 2005-04-05
Medium Priority
Last Modified: 2010-03-31

I want to add a picture from a URL in my application, lets say is this one:
How can I do it? any example?
thank you!!
Question by:ximotur
  • 2
LVL 15

Assisted Solution

aozarov earned 200 total points
ID: 13710617
Toolkit.getDefaultToolkit() .createImage(new URL("http://www.bull.net.au/adam/peckas%20pics/YamahaSuperstar1.jpg"))
LVL 15

Expert Comment

ID: 13710650
To draw the image: http://javaalmanac.com/egs/java.awt/DrawImage.html
But have a look at: http://javaalmanac.com/cgi-bin/search/find.pl?words=image
to pick the action you want to take.
LVL 92

Accepted Solution

objects earned 300 total points
ID: 13712668
create a label to display the image and add that label to your image hierarchy where required.

JLabel label = new JLabel(new ImageIcon(new URL("http://www.bull.net.au/adam/peckas%20pics/YamahaSuperstar1.jpg")));


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question