JFileChooser - File save as

Hi,
I have a method in my application called "export" which exports the JPanel content into a file.
I used the JFileChooser to let the users choose their desired location for saving the file.
The problem is unless user explicitly types in the file format, it saves the file with no extension.
How can I have formats like jpg, png in the File Type drop down menu.
The code is on a different computer, so dont worry about syntax errors, I just write the important bits:
JFileChooser jfc = new JFileChooser();
int answer = jfc.showSaveDialog(this);
if(answer==jfc.APPROVE_OPTION) {
   try {
      File file = jfc.getSelectedFile();
      ImageIO.write(Graph, "png", file); //Graph is what that needs to be exported 
   } catch () {}any help, highly appreciated, thanks

TheParthian wrote:
still got the problem,
I implemented the FileFilter and its two methods, but what I get in the menu is the string i used in the getDescription method.Yeah, that's what the description is meant for.
what if i want to include more than one extension?Add more filters.
Also, even if I choose that as the file type, it still saves it with no extension. Do I need to get the string from the menu and add it
manually to the end of file name?Yes, of course. (That is, you get the selected filter, determine the appropriate extension and add it, if the user did not explicitly specify an extension.)
BTW - why did you start a new thread? You could have continued in your old one http://forums.sun.com/thread.jspa?threadID=5334819&messageID=10440802#10440802.

Similar Messages

  • Is There Any Component Similar To JFileChooser To Save Information In File

    Hi All,
    I have an application in JSP where I need to save the some information from my jsp page into a file.Like JFileChooser opens the required files, is there any component similar to JFileChooser to "save" the information into a file???
    Thanks In Advance,
    Anupama M

    That's easy :) You can write it yourself.
    Imagine you've a List<Dto> where each DTO represents one row. Create a StringBuilder (or StringBuffer if you're still not at Java 1.5) and append each row value to it. Eventually add separators (comma, semicolon, etc) to it. After each row, eventually add a newline. On the end, stream the contents of the StringBuilder to the HttpServletResponse#getOutputStream(). Don't forget to set the headers accordingly.

  • JFileChooser File Name

    Hi!
    I'm using a JFileChooser to save in a local folder a file stored in my database and I'd like to set the File Name when I open the FileChooser, do you know how to do it ??
    Thanks !!
    TLLI

    JFileChooser.setSelectedFile()?

  • File save as type showing as GIF in Photoshop  CS6

    I have a problem/bug. When  I save for the web, select my file type ( png,wbmp,jpeg) it displays the file type as a Gif in the lower left eventhough the file saves in the correct format.  This is the version from the cloud download. Every file type displays this way?
    How can this be fixed?

    The original file must be Gif or you have some slices.
    On the top of the Save for web dialog press the Two Up button and the orginal will be on the left and the version to save will be on the right.
    Could you post a bigger screenshot as it's to tell from the small size you posted?

  • TWO CRITICAL BUGS: 1) File, "Save Page As" and 2) right-click the picture and select "Save Image As", both do not work at all in Firefox 27, 28, and 29!

    Note: capitals are used only to highlight important words.
    PLEASE, TAKE THESE COMMENTS ON TWO CRITICAL BUGS VERY SERIOUSLY BECAUSE THE BUGS DESCRIBED BELOW ARE SO CRITICAL THAT I CANNOT USE THE LATEST VERSION OF FIREFOX UNLESS THEY DO NOT APPEAR IN THE LATEST VERSION AND THEREFORE I AM FORCED TO REVERT BACK TO FIREFOX 26.
    I have Windows 7 64-bit and Firefox 26. I could not install Firefox 27, 28, and 29 due to the persistent presence of the two critical bugs described below. I have 8 GB of RAM and an Intel quad-core processor and a lot of hard disk space available.
    I installed Firefox 27 and then Firefox 28 a while back and these two bugs described below were still present and now I have just checked again with Firefox 29 by installing it and yet again, these two bugs described below are present!! UNBELIEVABLE THAT THESE TWO CRITICAL BUGS ARE STILL PRESENT IN FIREFOX 29 WHEN I CLEARLY INFORMED YOU ABOUT THEM IN THE HELP, SUBMIT LINK OF FIREFOX!!
    I am forced to revert to Firefox 26!
    First, I use Windows 7 64-bit and I always use Firefox with at least 120 tabs opened. BUT I have 8 GB of RAM, an Intel core i7 quad-core processor and more than 1 TB of hard disk space. Consequently, I do not understand why I would have these two critical bugs.
    With Firefox 26, I also have at least 120 tabs opened when I start Firefox and I do not have the two critical bugs described below, therefore I do not believe that the number of tabs is the reason of the two critical bugs that are present in Firefox 27, 28, and 29.
    ---FIRST CRITICAL BUG:
    When I open ANY web page and do File, "Save Page As", the window that is supposed to open to locate the folder where I want to save this web page does NOT open at all, even if I wait a long time to see if it opens.
    Same problem happened with Firefox 27, 28, and now 29!! When I reverted back to Firefox 26, this problem did NOT happen anymore!
    ---SECOND CRITICAL BUG:
    When I use Google Images, for instance entering model in the search field of Google Images and then pressing enter.
    Then I select any picture, open to a new tab this selected picture, then open a new tab by selecting the option View for this picture. Then right-click the picture and select "Save Image As".
    Again, the window that is supposed to open to locate the folder where I want to save this picture does NOT open at all, even if I wait a long time to see if it opens.
    Same problem happened with Firefox 27, 28, and now 29!! When I reverted back to Firefox 26, this problem did NOT happen anymore!
    ---THESE TWO CRITICAL BUGS DO NOT APPEAR WHEN I USE INTERNET EXPLORER 11.
    I have no idea if you will be able to reproduce these two critical BUGS but I can assure you that they are not present when I use Firefox 26 and they are present when I use Firefox 27, 28, and 29. More, be aware that I have at least 100 tabs opened but I also have this same number of tabs opened in Firefox 26 and yet I do not experience these two critical bugs when I have Firefox 26!
    Once again, these two bugs touch at two vital, critical very basic functions of Firefox and therefore I will NOT be able to use any version above 26 if these two bugs are still present, as they are present in Firefox 27, 28, and now 29!!!
    Please, make it a priority to solve these two critical bugs. Thanks.
    I did read a post related to the same issues “Firefox stops responding when trying to "save page" or "save image" | Firefox Support Forum | Mozilla Support” at https://support.mozilla.org/en-US/questions/991630?esab=a&as=aaq
    I am still reading it again to try to figure out exactly what the person did to make his problems be solved, as the post is not clear at all on what solved the problems!
    In any case, all the suggestions proposed in this post do not work and I surely cannot do a system restore when it is obvious that the two bugs do not appear in Internet Explorer.

    First, I sent an email to the author of PhotoME to inform him of the serious issues his addon caused with Firefox latest versions.
    Now, for those of you who do not have the PhotoME addon and yet experience the same problem that I had and that I described above, I suggest the following strategy.
    As PhotoME did cause these problems with Firefox latest versions, I am pretty covinved other addons probably might cause these problems too. Therefore, adopt the following method.
    Test one addon at a time to see if this particular addon is behind your Firefox issues like the ones I had.
    So, disable one addon only at a time. Then close your Firefox and restart it from scratch and see if you still have your Firefox problems. You must restart the Firefox browser from scratch. If you still have these Firefox problems, re-enable the disabled addon, restart your Firefox (again!) and repeat the same method for every single addon that you have.
    Try to be selective by choosing first addons that are more likely to cause your Firefox problems such as not very well-known or not very popular addons (like it was the case for the PhotoME addon).
    If this method works or if it does not work, report it on this web page so that others can be helped with your comments.
    I hope this method will help you because I was really upset that I had these Firefox problems and I first thought it was the fault of Firefox, only to discover later that this PhotoME addon was the culprit and had caused me such upset.

  • After completing my upgrade to Adobe Reader 11.0.10 When I attpemt to use "Tools/File/File Save As" from IE 11 I get a "Adobe Reader is not Responding" and my browser is locked up.

    After completing my upgrade to Adobe Reader 11.0.10. when I attempt to save an online PDF to my local drive I receive a blank window where I would expect to see file directory structure to save to.
    No local directories are displayed for "Saving To", it is all blank.   When I try to Close (by clicking X)  the "File Save As" box a message pops up on top that says "Adobe Reader is not Responding"  It locks up all of my IE windows, not just the one with the PDF doc.
    I then need to go Task Manager and stop the IE task.  All my browser windows are then closed.
    That is the only way to recover from the "Adobe Reader is Not Responding" message.
    This was not happening in previous versions of Reader.
    Tolls/File/File Save As always worked properly.
    I have installed IE 11 (11.0.9600.17690)

    Please don't post the same question multiple times!

  • HOW CAN I GET MY OLD TABS (FILE SAVE/BOOKMARK, ETC) BACK ON TOP OF SCREEN? I HATE THIS NEW LAYOUT!

    Today some kind of update happened on Firefox without me even approving it. Suddenly, I no longer have the tabs across the top that I REALLY liked--File/save as, Bookmark, View, etc. I WANT THEM BACK. Yes, I have found the little goofy drop-down icon on the right corner of the screen, but I don't like that. How can I get old view back???
    Thank you!
    ASM432

    Right-click on the Tab Bar and select '''Menu Bar'''.

  • Saving a PDF file when printing is not supported. Instead, choose File Save.

    I am using Mountain Lion (10.8.2) and I was using Adobe Reader version 9. In the past, I've always been able to print to file using the File -> Print dialogue but all of a sudden it stopped working. I read somewhere that installing the latest version of Adobe Reader (version 11) would remove the old printer, so I did so. It took me about an hour on version 11 to even find the pdf print to file option, but I am getting the same message. For what it's worth, when I try print to file from Microsoft Word, I have no problem. I have no idea why things changed all of a sudden, but does anyone have any idea how I can get this working again?

    I checked with Adobe.  No luck. 
    Allow me to clarify my problem: 
    I have Adobe Reader XI. I also use a Mac--imac and a MacBook Pro.   My adobe was updated on 12/24.  Prior to that point, I could open my print dialogue box and there was a PDF tab on the bottom left.  In the drop down menu there were many choices, including but not limited to Open in PDF Preview, Print PDF, Save PDF, email PDF.  If I selected one page of 30 pages from a document saved in Adobe, I could extract just that one page and save it or email it, without having to send the entire document.   After the update, when I open a PDF file using ADOBE READER XI, and then open the print dialogue box, and follow those same steps, I get the message "Saving a PDF file when printing is not supported. Instead, choose File > Save."   My question is why is this feature now unavailable and is there a way to fix it? 
    The answer I got from Adobe was that Adobe never had this function, so it must have been via my print or preview programs..which are apple.  Does anyone have any thoughts?
    Thank you.
    https://forums.adobe.com/message/7124567 

  • Pasting from a web page into a File-Save dialog no longer works; causes a freeze-up

    When I place an order on Amazon, I copy the order number, then print the invoice to .pdf. When the file save dialog comes up, I paste in the order number as part of the file name. I used to, that is. At some point the pasting part no longer worked: nothing (visible anyway) is pasted, but something is happening, as the file save process hangs, and I have to use task manager to kill it. Then, the print process is trashed - if you try to print again, you get an error - and I have to restart Firefox to clear that.
    This copy/paste procedure works fine in IE & Chrome.

    The only way I was able to reproduce what you described is to run the script after copying a picture.
    Here is a refined version.
    It make two attempts to grab text items from the clipboard.
    If both failed, it send an error message.
    --[SCRIPT table2text]
    Enregistrer le script en tant qu'Application ou Progiciel : table2text.app
    déplacer l'application créée dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:
    Il vous faudra peut-être créer le dossier Applications.
    Copiez vos données dans le Presse-papiers.
    menu Scripts > table2text
    Le presse-papiers sera alimenté par le composant Text ou utf8 du contenu initial.
    +++++++
    Save the script as an Application or an Application Bundle: table2text.app
    Move the newly created application into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:
    Maybe you would have to create the folder Applications by yourself.
    Copy your block of datas to the Clipboard.
    menu Scripts > table2text
    The Clipboard will be filled with the text or the utf8 component of its original contents.
    Yvan KOENIG (Vallauris, FRANCE)
    4 février 2009
    --=====
    on run
    try
    set the clipboard to (the clipboard as text)
    on error
    try
    set the clipboard to (the clipboard as «class utf8»)
    on error
    if my parleFrancais() then
    error "Pas de données texte dans le presse-papiers !"
    else
    error "No valid text data in the Clipboard !"
    end if
    end try
    end try
    end run
    --=====
    on parleFrancais()
    local z
    try
    tell application theApp to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z = "Annuler")
    end parleFrancais
    --=====
    --[/SCRIPT]
    Yvan KOENIG (from FRANCE mercredi 4 février 2009 21:49:14)

  • Save As Dialog Different on Exit vs. File - Save As...

    I started by opening a raw file through Camera Raw into a 16 bits/channel document.  My intent was to edit it a little and save as a JPEG.
    Photoshop CS5 Adobe added the ability to save a 16 bits/channel document as a JPEG, without first having to convert to 8 bits/channel.  BRAVO Adobe!  It's been great.
    However that functionality is specifically missing if one tries to exit Photoshop CS5 with an unsaved document.  Quite a lot of stuff is missing from the Save dialog that pops up there, actually.  It's like some kind of minimalist version.  Why?
    If I edit a 16 bits/channel document and try to exit before saving, this is the dialog it puts up:
    However, File - Save As yields this dialog:
    -Noel

    Thanks for clarifying. 
    I understand your thinking - you're trying to watch out for the newbie user and trying not to lose his/her layers, etc.
    The thing is, the way it is now makes it just a bit harder for a power-user who knows what he's doing to use Photoshop.  I've always disliked features that dumb systems down in the guise of protecting the less technical user at the expense of power.  This is not Photoshop Elements, after all!
    My case in point:  I opened a raw file, Camera Raw automatically applied the settings I had chosen and which the software had stored, I downsized the opened image, and wanted to save it as a JPEG.  It had no layers or other "fancy" attributes other than the fact that I always open raw files into 16 bits/channel depth (and I wouldn't want to change THAT default).  Since I don't, as a habit, leave applications open, I thought I would just close Photoshop and save the JPEG on the way out.  The dialog shown above defaulted to PSD, as I expected, but simply didn't allow me the choice to change it to JPEG.  So instead of just being able to blaze through the work in the quickest way, I had to cancel that dialog, choose File - Save As, then exit...
    Break in concentration and extra steps for the user who knows what he's doing.
    It seems to me that the act of prompting him on exit with a Save As dialog is all the notification needed that document information could be lost, and the user actively changing to another (lossy) format is the user's own confirmation that he/she knows what he/she is about to do.
    The more powerful Save As dialog just as it is today would be a perfect match for this.  It's a logical outgrowth of Save As A Copy, and the new feature where you're now allowing Save As JPEG directly from a 16 bit file.  By using the same dialog at the same time as making the product more powerful, you could simplify the implementation and save some future maintenance cost.
    -Noel

  • Click on download of pdf opens adobe acrobat reader, but then clicking on file save-as does not give a dialog box to change the name or location where it is sav

    Using Firefox 19.02
    When I receive an email with an Excel, Word, or PDF file attachment, and I click download, firefox opens up the associated program for all my users, however when you click on file>save-as you are not presented with the dialog box to perform a save.
    Excel and Word, no fix at all. Other than different browser or to click download, right click and go to folder, and then copy it out of there to another folder and open it.
    Help, what is going on here????
    Gordon rutherford

    BTW: using Adobe Acrobat Reader XI

  • Message error: "Saving a PDF file when printing is not supported. Instead, choose File Save."

    I have 2 problems creating a .ps file.
    As i know, there are 2 ways of creating a Postcript file from a PDF.
    The first is from the Print monitor. I go through menu File/Page Setup i give the exact dimensions from my spreaded pages and after that i go to Print and when this window opens,
    i go down and left and i open the pop-up menu on"PDF" and i choose "Save PDF as Postscript"
    There is where i get the above error message :
    "Saving a PDF file when printing is not supported. Instead, choose File > Save."
    And the second scenario, i get an equal problem.
    If i go to Page setup and give the right dimensions of my spreaded document, after that i go to the File/Save as command, there is choose from the bottom pop-up menu, the option at Format: Postscript
    If i do that i get the following message:
    "The document could not be saved. An internal error occured."
    What is wrong with all this?
    Can anyone help me out?
    System preferences.
    Mac OS X 10.4.11
    Acrobat professional 8.1.2
    Thank you

    Jon Bessant asked:
    "Does this occur on every PDF file? The internal error message that is ..."
    Yes, it happens on every PDF

  • Problem printing with Adobe Acrobat X pro. No File Save As dialog

    We have a C++ program to print a formatted report, by selecting the configured  printers. "Adobe PDF" printer is available on install of Adobe Acrobat Pro.
    During report print  when "Adobe PDF" printer is selected, the report use to get printed in a PDF document & saves at the path provided by the User.
    Internally it uses printer APIs like  OnBeginPrinting, StartDoc, OnPrepareDC, StartPage, OnPrepareDC etc.
    Report printing was working fine with Adobe Acrobat Pro 9.1. But since I installed Adobe Acrobat X pro (with update as 10.1.3) I am unable to print PDF document using "Adobe PDF" pinter.
    StartDoc API does not pops up the "File Save As" dialog at all.
    Any help in this regard, would be very useful.
    Note: My code is working fine, if I use freeware like CutePrinter.
    Thanks,
    Amit Agrawal

    Interesting. My approach would
    1. Try on a different system if available. If still bad...
    2. Try to create a simple test application with CreateDC and StartDoc, and really nothing else not absolutely needed.
    Test that.  If it is good, look for other problems in your application (e.g. memory overwrite).
    If your little example is still bad, post it here and other people can try and compare your results.

  • I have a word document that I have put hyperlinks in and turned into a pdf.  When I email and receiver opens in iPad the document is blank.  When I do a file save as pdf the document appears and the hyperlinks work but the document has much of the content

    I have a word document that I have put hyperlinks in and turned into a pdf.  When I email and receiver opens in iPad the document is blank.  When I do a file save as pdf the document appears and the hyperlinks work but the document has much of the content turned into symbols.  What is going wrong?

    You select the printer properties and set the appropriate page size (I think there is a place to set it in PDF Maker too, but not sure). In the printer, this is equivalent to putting the proper paper in the printer.

  • File Save As Other Reader Extended PDF Enable Commenting & Measuring GRAYED OUT

    I have an PDF form created in Adobe LiveCycle Designer ES 10.0.
    When I open in Reader, All the "Sign" options are grayed out.
    Under "Properties" Signing is allowed but Commenting is not.
    From all I have seen, I hope that allowing Commenting will allow me to use the sign features.
    The only solution I'm finding on the internet is below:
    File > Save As Other > Reader Extended PDF > Enable Commenting & Measuring
    It is grayed out in my (latest version of) Acrobat pro.
    **Is there a way to make this option available?**
    **Will this even solve my problem?**
    **Is it possible that it is impossible to use these features on this document?**
    At this point, I've spent about two and a half hours on this issue and haven't been able to find a solution. Very frustrated.
    Thanks.

    Thanks. I'm not an IT person and needed that lead.
    In the end, I just printed to Adobe PDF and then was able to use the commenting options (once I had flattened it). For those who might come across this - this is one of the only ways to flatten a XFA PDF.

Maybe you are looking for

  • "The disk could be not read from or written to"

    my iPod has never worked well, everytime I would add some more songs, iTunes would delete all my music (I got past that by choosing to manually sync it)... But I could always manage to transfer some songs to it(after reading the whole Apple support s

  • Use of old BTVision box in 2nd room now on YouView

    Hi, I have had a YouView box pretty much from launch, and when tidying up cupboards this week found my old BT Vision box (black variety). I was wondering if I could reuse this box in another room just as a Freeview receiver/recorder so not as a full

  • Differnce between BAPI and FM for MIRO

    Hi All, What is the difference between using the BAPI_INCOMINGINVOICE_CREATE or MRM_INVOICE_CREATE. I have a situation where i need to use the CALL transaction of MIRO as i cannot use the BAPI_INCOMINGINVOICE_CREATE. THough i have done a recording an

  • Messaging Server 6.3 proxy IMAP to UWash IMAP server

    We have a Sun Java Messaging Server 6.3 set up and we'd like to migrate our users a few at a time from an older mail server running UWash IMAP (v2006g) to the new Sun Messaging server. I am told by a Sun Engineer that this is possible by setting the

  • Tidying photos between devices

    Hi there, I have an iMac and a Macbook Pro (which I take away with me)... as a result, my photos are a mess! I have some that are on both, some that are on and not the other and vice versa. It would take me forever to sort through them all individual