Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Swing / AWT / SWT
JFileChooser to save file
Danny Paul
Greenhorn
Posts: 1
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi,
i m new to
java
, i m trying to learn the GUI swing.
can anyone tell me how to save a file using JFileChooser.
i know a method jf.showSaveDialog(null). but how to use this method to save a file.
Danny
Rachel Swailes
Ranch Hand
Posts: 434
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Once you show the dialog, the user selects a file and then presses the APPROVE_BUTTON. After that it is up to you to physically save the file.
int option = chooser.showOpenDialog(parentPanel); if(option == JFileChooser.APPROVE_OPTION){ if(chooser.getSelectedFile()!=null){ File theFileToSave = chooser.getSelectedFile(); //Now save the file
Cheers,
Rachel
chris forbes
Greenhorn
Posts: 1
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
JFileChooser fileChooser = new JFileChooser(System.getProperty("user.dir")); int returnVal = fileChooser.showSaveDialog(null);
Campbell Ritchie
Marshal
Posts: 80780
489
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Welcome to the Ranch
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Jfilechooser saving files with file extension
How to use menu event
file dialog
Getting correct filename with JFileChooser
save with JFileChooser
More...