This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes what is the actual use of getselecttedfile() method in jfilechooser ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "what is the actual use of getselecttedfile() method in jfilechooser ?" Watch "what is the actual use of getselecttedfile() method in jfilechooser ?" New topic
Author

what is the actual use of getselecttedfile() method in jfilechooser ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

see i know that getselectedfile returns the instance of the file but here i m saving a file offcource i m taking the file name from the user but why getselectedfile() method is used in this method
i understand that at the time of reading a file we ll need getselectedfile() to get the files instance so that we can read that file
but i didnt understand what the method is doing here
i mean getselectedfile() method


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4341
    
    7

How else do you know where to save the file, if you don't use getSelectedFile()? You're using a Save file dialog to allow the user to select a location, and that method tells you what they've chosen.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

Matthew Brown wrote:How else do you know where to save the file, if you don't use getSelectedFile()? You're using a Save file dialog to allow the user to select a location, and that method tells you what they've chosen.

you mean to say which location the user wants to save the file
the getselectedfile() that ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Yes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Minh Nam
Ranch Hand

Joined: Sep 10, 2011
Posts: 57
According to the Java doc:


public File getSelectedFile()

Returns the selected file. This can be set either by the programmer via setFile or by a user action, such as either typing the filename into the UI or selecting the file from a list in the UI.

Returns:
the selected file


Make a habit to read the Java doc may save our time!


Advanced java topics
 
Consider Paul's rocket mass heater.
 
subject: what is the actual use of getselecttedfile() method in jfilechooser ?
 
Similar Threads
How to divide File in Java
how to delete an object from heap ?
problem on reading the content of a file which has been uploaded in a remote ftp server
How to merge two files keeping leading blank spaces
fix reading only the last line of the file?