Results 1 to 8 of 8
- 05-18-2011, 03:33 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 23
- Rep Power
- 0
- 05-18-2011, 03:41 PM #2
- 05-18-2011, 03:44 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 23
- Rep Power
- 0
- 05-20-2011, 08:46 PM #4
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
Hey buddy try this code, i have also using the same in my application::
if (fileResult == JFileChooser.APPROVE_OPTION)
{
File f = photoChooser.getSelectedFile(); //Select the file
String path = f.getPath(); //get the path of file
Image image = Toolkit.getDefaultToolkit().getImage(path); // Now from that path get an image object which stores the file as an image object
}
//Now call that image object as for example a jLable icon:
imageLable.setIcon(new ImageIcon(image));
Hope this will help you....
Much luck!
- 05-21-2011, 10:03 PM #5
Member
- Join Date
- Jan 2011
- Posts
- 23
- Rep Power
- 0
hey there !...first of all thanks very much for the help ..but I still got one question...do you have to use this code in your actionPerformed method ? or is there another method specific for the jFileChooser like ItemListener or something? I mean how do you add the event if the "Open" button (from the filechooser) is pressed? or is it this line :
if (fileResult == JFileChooser.APPROVE_OPTION) ...approve_option = the open button?
Thanks !!
- 05-29-2011, 11:14 AM #6
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
Dear APPROVE_OPTION is static final integer value returned by JFileChooser...
Simply talking it is the "confirm" integer that makes sure that OPEN button is pressed successfully, or you can say that the file is selected successfully......
Before if statement you have to initialize the fileResult integer as:
int fileResult = photoChooser.showOpenDialog(null);
this will done two work: 1) opens file chooser
2) initializes fileResult integer
Now, rewrite whole statements in that button action performed method by which you want to open the file chooser.....
- 05-29-2011, 12:39 PM #7
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Please don't spoon feed, the op doesn't really get much help if he isn't thinking about it at all.
Also, if you do post code, please use code tags:
[code]
YOUR CODE HERE
[/code]
- 05-30-2011, 02:31 PM #8
Member
- Join Date
- Jan 2011
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
How do I substitute any variable for a hardcoded variable
By Weazel Boy in forum New To JavaReplies: 11Last Post: 07-07-2010, 06:02 AM -
Store the decimal number into an variable
By fataguila in forum New To JavaReplies: 4Last Post: 02-01-2010, 07:22 PM -
:large file upload to server(chunk upload)
By tommy_725 in forum NetworkingReplies: 0Last Post: 10-16-2009, 12:21 AM -
how to store the previous of a variable
By Randa in forum New To JavaReplies: 7Last Post: 09-22-2008, 08:16 PM -
Is it possible to get and store items to a variable in a combo box?
By Soda in forum New To JavaReplies: 2Last Post: 12-05-2007, 01:19 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks