This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Get image through a file explorer and save it in an object attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Get image through a file explorer and save it in an object attribute" Watch "Get image through a file explorer and save it in an object attribute" New topic
Author

Get image through a file explorer and save it in an object attribute

Kabir Goro
Greenhorn

Joined: May 04, 2012
Posts: 1
Hello,
i'm quite new to Java and i'd need to do the following. I post here because it seems the correct section.

I need to get an image file through an explorer and save this file in an attribute of an object i already created.

Let's say i have the class Movie, in which i have the the attribute

and i create an object called movieObj, of course an istance of the Movie class.

I now want to create this file explorer (maybe i can use JFileChooser?) and i want to save in movieObj.poster the image file chosen with the explorer.
Keep in mind i want to save the actual file, not just the path.

Can i do this? Please avoid answering with lots of code lines, they are ok if they come with an explanation though. I want to understand how things work
Thanks a lot in advance, eagerly waiting for your answers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4206
    
    3

Read the API for JFileChooser and follow the link to the tutorial on How to Use File Choosers. Then go through the section of the same tutorial titled Reading/Loading an Image.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Get image through a file explorer and save it in an object attribute
 
Similar Threads
Combining two files to create a new file and then reading it...
Creating image jpeg file from a image object
IE and NN Compability
how to get image from JPanel
Creating a File object from a java class, when both are deployed in the same package!