Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Minh Nam
Ranch Hand
Posts: 57
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic