• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

In JFileDialog how to use the save window

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used the open window with JFileDialog which gives me the opendialog , how do i use the save dialog where the user can type in his text & save the file with a name of his choice
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
I won't describe in details. I think you meant JFileChooser when u said JFiledialog. The JFileChooser will simply return the absolute path of the folder and the filename . You will have to do the saving yourself, just like you read the file after you open the open dialog of the JFileChooser and get the name of the file.
[code]
JFileChooser filechooser=new JFileChooser();
if( ImagerGlobal.ImageFileChooser.showOpenDialog(this)==JFileChooser.APPROVE_OPTION)
{
String absolutefilename= filechooser.getSelectedFile().getAbsolutePath());
File file=new File(absolutefilename);
FileInputStream fis=new FileInputStream(file);
//now save the data into this file input stream
//and then close the file input stream
}
hope this helps
regards
Tanveer
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at the tutorial from Sun. Here is a line directly from it. You can get there by clicking the how to use link in the API.
int returnVal = fc.showSaveDialog(FileChooserDemo.this);
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic