JFileChooser opening with showSaveDialog

Hello!
I have a problem. I want to save a file so I 've created a JFileChooser which opens in the showSaveDialog mode. My problem is how can I have the name of the file predefined so that the user will only choose the directory in which he wants to save the file?
Thanks in advance!

Ok I sussed it.
If this is for a class please definitely make sure you add comments attributing where you got this code from.
package tjacobs.util;
import java.awt.Component;
import java.awt.Container;
import java.awt.TextComponent;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;
public class ComponentMapper {
     public static interface MappedFunc {
          public void func(Component c);
     public static void map(Component c, MappedFunc func) {
          func.func(c);
          if (c instanceof Container) {
               Container con = (Container)c;
               int count = con.getComponentCount();
               for (int i = 0; i < count; i++) {
                    map(con.getComponent(i), func);
     public static void main(String[] args) {
          JFileChooser fc = new JFileChooser();
          MappedFunc mf = new MappedFunc() {
               public void func(Component c) {
                    if (c instanceof JTextComponent) {
                         System.out.println("found");
                         final JTextField tf = ((JTextField)c);
                         tf.setEditable(false);
                         tf.getDocument().addDocumentListener(new DocumentListener() {
                              public void insertUpdate(DocumentEvent de) {
                                   Runnable r = new Runnable() {
                                        public void run() {
                                             tf.setText("");
                                   SwingUtilities.invokeLater(r);
                              public void removeUpdate(DocumentEvent de) {
                              public void changedUpdate(DocumentEvent de) {
                         while (c != null) {
                              System.out.println(c.getClass());
                              c = c.getParent();
                         //disable the textfield
          map(fc, mf);
          fc.showSaveDialog(null);
}

Similar Messages

  • Mavericks wont save and open with my preferred desktop image

    After installing Mavericks my iMac opens with the "rolling surf" desktop. I can then start my preferred desktop from a saved 'photo but when I retsart the iMAc it reverts to "rolling surf". How can I get it to remeber to open with MY choice rather than Apple's?

    Hi, as dgriffiths-leics-gov-uk said, you have to sign your applet, check the Jar files, and signing applets tutorials at java's site, or else the following URL:
    [http://forum.java.sun.com/thread.jsp?forum=54&thread=383859]
    ...there was a posted message which I replied with all the process condensed to sign and add permissions to an applet, including the use and creation of the Jar file, its way to be signed; and, the HTML code you shall use. That way you can use
    JFileChooser class and its methods in your class; therefore, the File Choosing dialog will be shown and you'll be able to Open and Save user files.

  • Open report with "Save as" and "Open with" dialogue

    Hi,
    I'm using jasper reports within my application. I manage to open them in a new window but in that case the url containing JasperServer username and password is shown. I would like to open the report without showing the url.
    I tryed using a database procedure (http://sqlcur.blogspot.com/2009/02/jasperreports-in-apex.html) but all I get is a alert window saying "file does not begin with ' pdf-'". Couldn't see what is the problem (I used the same procedure as Ino has in his example) so I thought of another way. Is it possible, when someone clicks a button to open a report, to open that report with a "Save as" and "Open with" pop up window?
    The javascript function that I use:
    <script language="JavaScript" type="text/javascript">
    function openLAPopUpJasper(url){
    w = open(url,"winLov","toolbar=false,menubar=false,location=false,resizable=yes, //scrollbars=yes,status=yes,fullscreen=true");
    if (w.opener == null)
    w.opener = self;
    w.focus();
    </script>
    Thanks in advance!
    Edited by: Josip on Oct 29, 2009 2:55 AM

    Anyone?

  • Firefox will not open new windows, opens with session restore every time I use it, and won't let me open the throubleshooting tab... Why?

    Whenever I try to open a new window, nothing happens. This includes clicking ctrl+N and through the drop down menu.
    Also, whenever I start firefox to browse the internet, it always open with a Session Restore with the previous session listed, even though I closed all the tabs and shut it down normally without any prompts telling me about saving multiple tabs.
    Finally, when I tried to troubleshoot this problem, the tab never appeared. The only options that work on the Help Menu are:
    - Firefox Help (after a few clicks)
    - Report Broken Web Site
    - Check for Updates
    - About Firefox

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    There are other things that need your attention.
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    *Shockwave Flash 10.0 r45
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://kb.mozillazine.org/Flash
    *http://www.adobe.com/software/flash/about/

  • Email pdf to iPad - is there a way to open multiple pdfs at one time without having to hold each individually and open with adobe reader?

    I have a large number of pdf files to send to an iPad and it is taking forever to hold down each one and then choose to open with adobe reader.  Just wondering if there is a way to select all from the email to do the same action?

    Not that i know of but an alternate would be to use something like dropbox instead of mail. Their app works very well.

  • How can you get your homage address to open when you open new tabs? My homepage is Google, but my new tabs always open with Yahoo.

    On my old computer, all my tabs always opened to what my homepage was set to: iGoogle. Now with my new computer, my homepage is set, but all new tabs open with Yahoo! I've tried looking at tab setting but don't see a place to set it. Help!

    The behavior that you have is not the default Firefox behavior, which always opens a blank tab. You will have an add-on that is causing this. Check for any Yahoo related add-ons to see if they have this option. The freeze net assistant add-on is another one that opens Yahoo in a new tab.
    There are add-ons that allow you to specify what should appear on a new tab, but these may conflict with the add-on that is opening Yahoo.
    * NewTabURL - https://addons.mozilla.org/firefox/addon/newtaburl
    * New Tab Homepage - https://addons.mozilla.org/firefox/addon/new-tab-homepage
    Another way of opening the home page in a new tab is to middle click on the home button in the navigation toolbar.

  • Removing obsolete file type associations from "Open With" menu

    Ever since I removed VMWare Fusion 3.x from my system, I've been unable to remove the Bootcamp file type associations that it created. For example, if I right-click on a PDF and choose Open With, this is a partial list of what I see:
    Adobe Acrobat Pro (default)
    Adobe Distiller (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    Adobe Fireworks CS4
    Adobe Fireworks CS4 (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    Adobe Illustrator CS4
    Adobe Illustrator (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    Adobe Photoshop CS4
    Adobe Photoshop CS4 (Mac) - Boot Camp partition (VMWare Fusion 3.0.0)
    ...and on and on and on. 17 additional entries for Fusion for PDS's alone. This junk is driving me crazy.
    I've tried rebuilding the Launch Services database with MacPilot and Onyx (the recommended fix that I've found on the web), but the entries still are there even after restarting Finder and rebooting my iMac. I'm at a loss to figure out how to get rid of these.
    Can anyone help me?
    Thanks!

    They are stored in the LaunchServices database. You can give this a try, but no guarantees. If you no longer use VM Fusion then I suggest following the information below on uninstalling software.
    Rebuild LaunchServices Database
    Open the Terminal application in your Utilities folder. At the prompt paste in the following command in its entirety:
    find /System/Library/Frameworks -type f -name "lsregister" -exec {} -kill -seed -r \;
    Press RETURN.
    Wait for the Terminal prompt to return after which you can quit the Terminal.
    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash. Applications may create preference files that are stored in the /Home/Library/Preferences/ folder. Although they do nothing once you delete the associated application, they do take up some disk space. If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application. In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder. You can also check there to see if the application has created a folder. You can also delete the folder that's in the Applications Support folder. Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item. Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder. Log In Items are set in the Accounts preferences. Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab. Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS. Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term. Unfortunately Spotlight will not look in certain folders by default. You can modify Spotlight's behavior or use a third-party search utility, Easy Find, instead. Download Easy Find at VersionTracker or MacUpdate.
    Some applications install a receipt in the /Library/Receipts/ folder. Usually with the same name as the program or the developer. The item generally has a ".pkg" extension. Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are also several shareware utilities that can uninstall applications:
    AppZapper
    Automaton
    Hazel
    CleanApp
    Yank
    SuperPop
    Uninstaller
    Spring Cleaning
    Look for them at VersionTracker or MacUpdate.
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • Photoshop-When opening image without tab view, image opens with only a portion in view

    I having an issue with CC.
    When electing in the preferences to not open image in Tabs. The images open with only about 25% of the image area showing. Forcing me to (command) 0 for full to screen preview or (command) +/- to see the image.
    I am not talking about seeing the image at 100% resolution just the entire image within the floating window without having to command before view.
    Sidenote: Adobe Customer Service is all based in India. I spent 4 hours on the phone only to hear that this is that way photoshop works.
    There would be no logical explanation for this. Since the first version of Photoshop this has not been the case.
    I think this should be called view porn with wife in the room mode. Other than that I see no point.
    Can anyone help?
    Lv
    Chadwick Tyler

    Moving discussion to Photoshop forum.

  • Adobe Creative Cloud doen't open with Mountain Lion, is it compatible?

    Adobe Creative Cloud doesn't open with Mountain Lion, is it compatible?

    Running Creative Cloud on 10.8.4 perfectly:
    have you tried repairing your disk permissions using Disk Utility?
    MtD

  • In finder, or say anything else such as downloaded files, I have to push open with in order to open the file. If I simply double-click on a document from finder, it does not open.

    Hey guys. I have this problem where when I try to open say a document from finder, I have to push "open with."
    Simply double-clicking does not work. I would greatly appreciate it if anybody could help.
    Another unrelated problem is that when I push to open itunes, it says that it is on a locked disk.
    Thanks

    Select a particular download file. Press COMMAND-I to open the Get Info window.  In the Open With section choose the desired default application from the dropdown menu then click on the Change All button.
    For .dmg files use DiskImageMounter (System/Library/CoreServices/ folder.)
    For .zip files use Archiver - same folder as above - or download TheArchiver - MacUpdate or CNET Downloads.

  • Trying to login to software program known as hamspher (vip simulated ham radio,  it downloaded the program but it will not allow me to login with call sign and pin.  it has to be opened with what they call a jar file.  how do i do this?

    trying to login to software program known as hamspher (vip simulated ham radio,  it downloaded the program but it will not allow me to login with call sign and pin.  it has to be opened with what they call a jar file.  how do i do this?

    This is compatible with Mac? Especially Snow Leopard (if that is what you'e running)?
    Have you considered posting your question in their forums?
    Here is some information re. the jar file:
    http://ostermiller.org/opening_jar_files.html

  • When I try open a .pdf file my Adobe Reader 11 only allows the download / save opening the related window and don't show me both options 1) open with ... and 2) save as.... probably someone flagged the choise... always perform this way ....

    When I try open a .pdf file my Adobe Reader 11 only allows the download / save opening the related window and don't show me both options 1) open with ... and 2) save as.... probably someone flagged the choise... always perform this way ....
    Could some one give help and let me know where I can probably find the settings option that allows me to change and switch to previous situation where it was possible to decide time to time how to proceed either opening the file or saving it ??
    Thanks in advance
    David

    What is your operating system?
    Open a PDF from where?  If online, in what browser?

  • SharePoint Foundation 2010 - Your client does not support opening this list with windows explorer when clicking Open with Explorer

    when I tried to open document library in Windows explorer view by click 'Open with Explorer', it popped up “Your client does not support opening list with windows explorer”
    OS: Windows Server 2008 Enterprise x64
    IE: 9.0 32bit
    webcient service is runing
    HKLM\System\CurrentControlSet\services\WebClient\Parameters and changed the BasicAuthLevel to 2 instead of 1.
    Anybody knows how?
    Thanks.

    Did you add your site to trusted site list?
    http://sharepoint.stackexchange.com/questions/15098/your-client-does-not-support-opening-this-list-with-windows-explorer
    --Cheers

  • I would like the window that opens with a new tab to be my home page. Instead it's YAHOO and I don't like it. How do I fix this so new tab is homepage?

    When I Ctrl+t to get a new tab it opens with YAHOO as the page. I would like it to open my HOMEPAGE.

    You can look at one of these extensions:
    * NewTabURL : https://addons.mozilla.org/firefox/addon/2221
    * New Tab Homepage : https://addons.mozilla.org/firefox/addon/777
    You may need to check other extensions if they are overriding the page that opens in a new tab.
    If you have AVG software then see:<br />
    AVG Antivirus and Security Software - AVG Security Toolbar Help New Tab Search<br />
    http://www.avg.com/special-toolbar-how-to-disable-search-tlbrf.tpl-mcr1\

  • I have a mac air and an iMac and both have Pages. I use Pages on my air and save all documents to iCloud. I can see them on my iMac but it won't open with Pages. It becomes visible if I change it to open with preview but I can't interact with it.

    I have an mac air and an iMac 5k - pages runs on both.  I use pages on my air and save all my documents to iCloud drive. I can see the documents on my iMac but some won't open in pages which is bizarre? They will open if I change it to open with preview but then all I can do is read it  - I can't add to the document - All I want is to be able to see all my documents on all my devices and to be able to have them sync so I can add to the documents from  any of my devices. I also have an iPhone 6 and an iPadair2 but I would be happy just to have the iMac and macair sync for starters. I have folders within folders in my documents,. The folders which contain pdf's and individual files open OK . The one I am having difficulty with is the file which I use for ongoing correspondence - in other words it is quite long - I keep adding to it  ( by copying letters in and letters out so I can see a sequential history of what has been going on by scrolling down ) in date order so that it could be 1 - 100 pages long - but I don't think the size is a problem. I don't understand why some folders can open and others not . Has anyone any suggestions please. I have been trying to get this to work for months since iCloud drive came in. It has got much better but it is still not good enough  - or maybe it's me?

    All I can suggest is that you open that file on the MBA and save it as a new file, then see if you can open the new one on the iMac.

Maybe you are looking for

  • BAPI_ACC_DOCUMENT_POST for field trading partner (bseg-VBUND)

    Hi, I am uploading journal entries in SAP by using this BAPI "BAPI_ACC_DOCUMENT_POST". Here program works fine now i want to give trading partner (bseg-VBUND) in line item but i cant find appropriate field in this BAPI for trading partner so that i c

  • Webutil- How to open text file by using Wordpad

    Hello: Is it possible to open the text file either from client or server (sun) by using the wordpad? I was able to open it with Notepad; however, it was given the rigth format such as new line. WEBUTIL_HOST.NONBLOCKING('CMD /C NOTEPAD'||:input_select

  • No number range found which is maintained in pr10

    Hi All, I ahve maintained nuber range for travel in PR10 for the respective personnel area....but the employee when trying to put the expeses in PREX....here the error is "No number range found for 01 RP_REINR ZONC" I have don the same in sand box an

  • Sales order with same PO no.

    Hi all, Kindly suggest for the beolw, when a Sale order is created with Purchase order number for which already a SO exists a warning message should pop up ("PO NUMBER EXISTS"), There is a possibility that the end suer might create 2 sales orders for

  • String equals, matches,, startsWith..endsWith...

    I got some problem and it is very weird for me ... For example: call method: toCompare("hello"); method: toCompare(String s) { String sa [] = //get all the filename from a file ...// for examle sa contain hello // loop if (sa.equals(s) ...){ // it ac