aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes file dialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "file dialog" Watch "file dialog" New topic
Author

file dialog

pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
can we provide the sample code just like file tag in html.
ie. we have browse button and when u select the browse button u can select the file i your computer or create one file in specified directory in one computer.i have used filechooser.but unable toperform the operation just like file tag in html
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
I'm not sure I fully understand your request. Did you check out the Java tutorial section on JFileChooser? It contains information on how to display the appropriate type of dialog. You can configure it for Open, Save, directories or files only, and so on.

You only really use JFileChooser to get File instances using the getSelectedFile() method. Once you have this you can find the path of the selected file and then take the appropriate action (create it if the action is a save; open the file and read it for loading; just display the path as a string for information, etc).
pvsr rao
Ranch Hand

Joined: Oct 05, 2005
Posts: 102
using JFileChooser we can retreive a file by using getSelectedFile().
like that can we create one file under specified directory.if so tellme by which we can do this.i have tried .but no method haven't seen
Ko Wey
Ranch Hand

Joined: Sep 08, 2003
Posts: 67
I suspect you want your JFileChooser only to select directories,
then you can make a new file in the selected directory?

Very roughly, something like this:

JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showOpenDialog(component);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File directory = chooser.getSelectedFile();
File babyFile = new File(directory,"name_of_babyfile);
};
//etc....

of course baby-file does NOT exist: you still have to create it on disk
with FileWriter or FileOutputStream....

Hope I helped you!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: file dialog