0

I recently started learning java and am trying to make a simple GUI program that takes in a location of an image and then displays the it.

What would be the best way to do this??

3
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by Hockeyfreak889
0

haha i saw that tuturial using google earlier today. However i didnt really understand how the code it gives you works (yes i read the descriptions)

To load an image (which is the part i dont quite get) it gives you the following code:

try {
URL url = new URL(getCodeBase(), "strawberry.jpg");
img = ImageIO.read(url);
} catch (IOException e) {
}

if the folder the image is in is (C:\Users\General Use\Pictures) and the name of the file is "0118080951" where do these things go in the above code? i thought the C:\Users\General Use\Pictures would go in the URL place but i tried that and it didnt work

Edited by happygeek: fixed formatting

0

never mind i figured out my problem... forgot the .jpg at the end of the file name.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.