Clicking in empty area in JFileChooser selects the closest file

Hi,
I came across this behavior of JFileChooser that whenever the user clicks in an empty area within the file chooser window, the selection is set to the closest file or directory. Is there any way to configure JFileChooser that a file will be selected only if the user directly clicks on it? Clicking on empty area should preferably deselect the current selection. I am working with 1.5.0_01. This is the code I was working on:
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
public class FileFilterDemo {
public FileFilterDemo() {
public static void main(String[] args) {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".gif")
|| f.isDirectory();
public String getDescription() {
return "GIF Images";
int r = chooser.showOpenDialog(new JFrame());
if (r == JFileChooser.APPROVE_OPTION) {
String name = chooser.getSelectedFile().getName();
System.out.println(name);
Thanks

Use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.
Works fine on Windows XP with 1.5.0_11

Similar Messages

  • How to Dynamically Select the Data File for a Report at Print Time

    How do you configure a Crystal report to ask for the file to be reported on as the report is being printed, and allow the user to browse to the file?
    The environment is Crystal Reports XI, SP3, with ODBC connection to Sage Timberline Office data version 9.7.  The client names their Payroll unposted time file each pay period, and also needs to report on their posted data file, depending on the time period for the report.  The client will need to select both the date range and the file name.
    I have created a SQL statement in Add Command in Database Expert, which prompts for a file name, but it does not let you browse to select a file on the computer.
    Therefore, in the prompts when they print the report, the parameter offers the user a default file name similar to the name they currently use, so they only have to change the payroll period end date in the supplied file name to run the report successfully.
    The client is concerned that sometimes a user will name their data file differently, and not know how to input the file name into the Crystal report prompt at print time.
    My research on dynamic prompts showed you can link to fields inside the data record, but I did not see a way to dynamically link to select the actual files used in the report.
    Another question is that the naming convention used by the SQL query is different than the basic Windows file name, but I think I can handle that issue.
    The actual file name is typically similar to:
    04-10-11 BP NEW.PRT
    However, in the SQL query, the record ID looks like:
    PRT_00-00-00 BP NEW__TIME
    The SQL Statement using a parameter is:
    SELECT
    "PRT_CURRENT__TIME"."Employee",
    "EMPLOYEE1"."Employee_Name",
    "PRT_CURRENT__TIME"."Date",
    "PRT_CURRENT__TIME"."Units",
    "PRT_CURRENT__TIME"."Job",
    "JOB1"."BP_Emps_Used"
    FROM
    "PRT_CURRENT__TIME" AS "PRT_CURRENT__TIME"
    INNER JOIN "JCM_MASTER__JOB" AS "JOB1"
    ON "PRT_CURRENT__TIME"."Job"="JOB1"."Job"
    INNER JOIN "PRM_MASTER__EMPLOYEE" AS "EMPLOYEE1"
    ON "PRT_CURRENT__TIME"."Employee"="EMPLOYEE1"."Employee"
    WHERE "JOB1"."BP_Emps_Used" = 1
    AND
    ("PRT_CURRENT__TIME"."Date" BETWEEN
    {?As of Date} - 41 AND {?As of Date})
    UNION ALL
    ( SELECT
    "PRT_NEW__TIME"."Employee",
    "EMPLOYEE2"."Employee_Name",
    "PRT_NEW__TIME"."Date",
    "PRT_NEW__TIME"."Units",
    "PRT_NEW__TIME"."Job",
    "JOB2"."BP_Emps_Used"
    FROM
    "{?NEWPRT}" AS "PRT_NEW__TIME"
    INNER JOIN "JCM_MASTER__JOB" AS "JOB2"
    ON "PRT_NEW__TIME"."Job"="JOB2"."Job"
    INNER JOIN "PRM_MASTER__EMPLOYEE" AS "EMPLOYEE2"
    ON "PRT_NEW__TIME"."Employee"="EMPLOYEE2"."Employee"
    WHERE "JOB2"."BP_Emps_Used" = 1
    AND
    ("PRT_NEW__TIME"."Date" BETWEEN
    {?As of Date} - 41 AND {?As of Date})

    Hello,
    Sorry you'll have to contact Sage on how to do this. We can help you once you get connected but we can't help you get around their connection methods.
    There is no Preview Set Database Connection method you can use in CR Designer. The Designer assumes you select it first or use the Set Location option before previewing or refreshing the data.
    If you are doing this in the Sage program itself we can't help you, you'll have to contact Sage for assistance.
    Sage is an OEM Partner they are responsible for supporting their product and CR. If they have issues help you then they will contact us directly for assistance.
    Thank you
    Don

  • Selecting the first file from a group of opened files in Photoshop

    Hi, I've been digitizing microfiche with 200 or so pages photographed onto one image file, laid out in a grid pattern. I've been using actions in Photoshop to cut out one page, create a new file in Photoshop from that page, then return to the first, master file and do it again with the next page in the series. So when it is complete I have each individual page as an individual image file which I then save with a batch process. I've been doing this for a while and have managed to make it work but I always run into the problem, when creating this action again, of getting Photoshop to select that first master file each time instead of selecting just the previous file. I know I can get it to select the previous file, or the previous file -1, -2, -3, etc. I've somehow been able to get this to work in the past by creating an action that selects a large enough group back, like previous file -19 or something, and through some bug or sheer luck it has worked and will always select that first file. But it doesn't always work and it always takes some frustration to luck into it when it does. Now I can't seem to get it to work at all. Is there a straightforward way I can simply tell it to select the first file everytime? If not, does anyone know how or why the method I used previously sometimes works and sometimes doesn't, and how I can make it work again? I'm using PS CS5 in Windows 7. Thanks!

    Just put this code on a file and put that 'namedfile.jsx' inside the scripts folder on photoshop.
    Open or re-open photoshop to load the script and create an action linked to a shortcut selected by you and save this script going to File>Scripts>namedfile.jsx
    It is just to press the shortcut key and the active image go back to the image opened before.
    When it is the first one it runs the script the same but it remains there.
    Here is the script:
    // Go back to the previous opened image
    #target photoshop
    // Go back to the previous opened image (not the previous viewed) . If it is the first, it remain there.
    if(documents.length>0) {
        var thisIndexImage = getActiveDocumentIndex();
        var theDocs = app.documents;
        if ( thisIndexImage != 0 ) {
            var flatAnterior = theDocs[thisIndexImage - 1];
            } else {
            var flatAnterior = theDocs[0];
        app.activeDocument = flatAnterior;
    } else {
        alert ("You must have opened images to run this script.")
    // Get the active document number - the number of opening order
    function getActiveDocumentIndex(){
         var ref = new ActionReference();
         ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
         return desc = executeActionGet(ref).getInteger(stringIDToTypeID('itemIndex'))-1;
    If you want to go directly to the first of all the images (in opening order) it is simpler:
    Just create this script:
    var first = app.documents[0];
    app.activeDocument = flatAnterior;

  • Download  resources that are not listed in the JNLP file

    There is some way to download resources that are not listed in the JNLP file, and then
    ask for them with DownloadService ? (isResourceCached)
    thanks.

    currently, the jnlp spec requires DownloadService to access only resources specified in the jnlp file..
    changing this is a proposed RFE for the next spec version:
    4908304: JWS DownloadService should not require mention in JNLP file
    /Dietz

  • [SOLED] Firefox input type = file selects the wrong file

    When I have use a webpage in firefox that has an upload feature, Firefox often selects the wrong file. I can reproduce this problem by simply creating a form with an input tag like this:
    <input type="file" />
    When I enter the file selection screen and open fileA the input box contains fileA, fileB or fileC. It seems kind of random to me. I use KDE 4.5 btw, if that matters.
    Last edited by Wilco (2010-08-07 08:24:35)

    It seems to be some kind of kde problem. When I delete ~/.kde4/share/config/* it works fine. I tried deleting the all files in share/config starting with a-m and it still didn't work. Then I deleted every file from n-z and it didn't work so it's probably a combination of files that give these problems. I don't feel like setting up KDE all over again so damn, it's back to Icewm, again...

  • ODI to delete those members which are not present in the source file

    Hi John,
    Using ODI we can delete members by using delete option in the Operation column
    Fine. I would like to delete members from planning which are not there in the source file.
    For e.g if my source file has members A1,A2,A3,and A4 and Planning outline has A1,A2,A3,A4,A5 and A6. I would like to delete only A5 and A6.

    Hi John,
    Its only a one time process. The issue is, we have to concatenate two segments of the COA into one dimension in Planning. But if we concatenate it creates a cartesian product which is not the requirement. Only a particula value of segment 1 are to be joined with segment 2.
    E.g Company 1 is to be joined with Cost center 1.
    Company 2 with Cost center 2
    Company 1 should not get joined with Cost Center 2 and Company 2 with Cost Center1.
    So when we use ERPI and load the first outline it creates all the possibilities of the concatenation. So we would like to delete the unrequired members. If we have the values of the required members in a file, I would like to delete the unrequired members in the planning hierarchy.
    So would like to use the NOT IN function

  • Finder crush when I select the exported file with FCP/Compressor

    I exported an mpeg2 file from FCP using compressor, but when I tryed to select the output file in finder window the application crushed.
    Somebody can help me? thank you a lot, carlo

    How large was the original file? 7 gigs is an enormous m2v file. Anyway, it sounds like there's some kind of corruption going on. First repair permissions on your startup drive using the drive utility (in applications:utilities). It might be worthwhile to get DiskWarrior and run that on the drive. How much free space is there on your startup drive? If your drive is almost full, this could also cause problems.

  • Fider crush when I select the exported file with FCP/Compressor

    I exported an mpeg2 file from FCP using compressor, but when I tryed to select the output file in finder window the application crushed.
    Somebody can help me? thank you a lot, carlo

    What icon shows the m2v file? Compressor one? The problem must be in default application for that file and not in the file itself.

  • After downloading and updating my iPhone my apps are now backed up on my laptop and I can't move them back over to the phone. I tried to follow the instructions in Help section, but the screen where you are supposed to select the apps to share won't let m

    The screen where you should select the apps you want to share is greyed out. It won't et me drag them either. Any thoughts?
    Thanks!

    Hi skippy2012trev,
    Welcome to the Apple Support Communities!
    I understand that you updated your Apple Id and password but now you are being prompted for the old information in iCloud. You are on the right track by changing the Apple ID back to the previous email address temporarily so that you can sign out. You should not need to verify the email address. After you edit the Apple ID back to the old email address and then sign out of iCloud on your iPhone, edit the Apple ID back to the address you would currently like to use. There is no need to change the password again, only the email address, unless you prefer to update the password again.
    If you're asked for the password to your previous Apple ID when signing out of iCloud - Apple Support
    Change your Apple ID temporarily
    If signing out and back in to iMessage or FaceTime didn't help, try these steps:
    Change your Apple ID to the Apple ID you used previously. You shouldn't need to verify the email address.
    Tap Settings > iCloud. Complete these steps only if the Find My [Device] setting is turned on:
    Scroll down and tap Sign Out, then tap Sign Out to confirm. If you're using iOS 7 or earlier, tap Delete Account, then tap Delete to confirm.
    Tap Keep on My [Device] or Delete from My [Device]. In either case, your data remains in iCloud and will be updated on your device when you sign in to iCloud again.
    Enter the password for your previous Apple ID.
    Change your Apple ID to the new email address that you want to use. You'll need to verify the email address.
    Return to Settings > iCloud and sign in with your new Apple ID.
    Cheers,
    Joe

  • Signature preferences (AIR) are not saved in the fla file

    Hi,
    - I create a new fla file in Flash CS5 Professional,
    - I go to publish settings and select AIR2 as the target
    - I click the Settings button on the right
    These settings are supposed to be saved with the fla file, since all of them are related to the project.
    Application name, icons, files to include, etc, are all preferences related to the fla file of which you are editing the settings.
    However, when you go to the "Signature" tab and select a digital certificate to sign the air application with, this setting will NOT be saved into the file.
    Instead, whenever you publish ANY air application, it will use by default the last certificate you have used, even if you used it to publish _another_ application.
    That is absurd, because this is a tab within the "publish settings" and all publish settings are specific to a fla file.
    Is there a way to fix it? Perhaps some global preference somewhere, or a windows registry key?
    Or is it just a bug?
    thanks
    m.

    I would think the signature is the signature specific to the user/company who has opened the fla and is used to identify the developer/company who has created the application.
    Now if the signature setting was saved on the fla, and the fla is opened on a different guys machine,
    first - he would not have the signature that you had and at the same location
    second - it does not make sense to him, since he is not you.
    It is unlikely that that a person/company creating applications would sign the swf/air with different signatures.
    So I would think that the current behaviour is correct and the signature is specific to the person who has opened the application rather than the application itself.
    Hope this explains it.

  • Its great you all decided to update to a new system but my bookmarks are still stored under the .json file and i would like them back

    my computer crashed and i need to restore my bookmarks but it wont recognize the json bookmark file. it is real nice of firefox to update how bookmarks are saved and not tell people so they know to change their backups WTF

    ''emeralddragon [[#question-1051030|said]]''
    <blockquote>
    but it wont recognize the json bookmark file
    </blockquote>
    What do you mean be this?
    Bookmark / History Backups
    Type '''about:support'''<Enter> in the address bar.
    Under the page logo on the left side you will see '''Application Basics.'''
    Under this find '''Profile Folder.''' To it’s right press the button
    '''Show Folder.''' This will open your file browser to the current
    Firefox profile. Now '''Close Firefox.'''
    Enter the '''bookmarkbackups''' folder. This is where Firefox makes backups
    of your bookmarks. Look for the '''jsonlz4''' file you want to restore
    (check the time / date / size). Right click on that file and select '''Copy.'''
    Now go back to the profile folder where you started. Rename the file
    '''places.sqlite''' by adding '''.old''' to it. Now right click in the folder
    and select '''Paste.''' The file you just pasted here, rename it to
    '''places.sqlite.''' After you are done, restart Firefox.

  • How to Select the Latest file from Application Server?

    Dear All,
    I am working on object, which had requirement to Pick the file from application server.
    The Application server contain the files in ‘/temp/sms/’ directory. The files are having the name Like ‘smsqry_yyyymmddhhmmss.txt’ and I have to Pick the Latest file (Base on file name for eg. 'smsqry_20060713102333’) from that all and after getting the file I have to delete the file from application server.
    So How to do this.
    Regards

    hi,
    look function group EPSF-
    esp. fm EPS_GET_DIRECTORY_LISTING
    if you're looking fo OS-date and time
    look here:Re: How do I convert MTIME to date and time?
    A.
    Message was edited by: Andreas Mann

  • My tv show and movies are getting stuck in the processing file stage

    I purchased some TV show episodes and movies on itunes. They are stuck in the processing file stage, and wont let me pause them and restart. When I close itunes it wont open again. I have to restart my computer. Please help, they have been stuck for over a week now.

    please contact me on [email protected]

  • MS publisher 2010 to PDF using Adobe Acrobat X Pro produces outlines on some of my images that are not there on the publisher file!

    I am helping a client publish a book through Createspace. We are both using Windows 8 OS. She created her document in MS Publisher 2010. I made the necessary edits to her book, (111 pages) and saved it as a pdf for commercial printing. The resulting pdf puts lines on some of the images. (All the images are jpg format, but it only happens to some.) I have tried creating the pdf in several different ways including print to PDF, Save as PDF, and Save and Send Wizard for commercial printing. I have also tried deleting and reinserting the images. I don't know what else to try. Does anyone have any ideas.
    The image below shows what I mean. On the left is the Publisher File, on the right is the PDF.

    I agree with your statement; even for a particular document, if I choose to "Print on both sides" and then print again immediately after, "Print on both sides" will be deselected.
    However, I'm not sure what you're implying by you're statement. I'm asking precisely why this setting isn't sticky. Acrobat uses a non-standard printer dialog; in the usual dialog I can easily set a defualt duplex setting. I almost always want to print duplex. Why can't I do this by default in Acrobat?

  • I edited RAW files as DNG's and need the xmp files- are they embedded in the DNG files?

    I was editing for someone else and the like the xmp files to see the RAW adjustments- I edited them as DNG because that is how I'm used to doing it. Now I know but they want me to supply the xmp files which did not write. Is there a wat to do this or do I need to re edit them as RAW's?

    DNG files don't have XMP sidecar files. Everything is written to the header of the DNG. And as far as Lightroom goes, It will be necessary for you to specifically write the data to XMP files. Otherwise the adjustments will only be stored in the catalog.

Maybe you are looking for

  • Missing Scanned Photos in Iphoto

    Hi I used my iPad and iPhone to scan a bunch of old photos.  I then uploaded to iPhoto on my iMac.  I just went into iPhoto and they are all gone!  The folders I made are there along with the titles but the photos themselves are not there.  Help!!

  • Problem integrating slideshowpro flash photo gallery into existing page

    Hi, I have a photo gallery made with slideshow pro which you can see on the page http://theoldfort.com/slideshow/slideshow.html. All the files are located in a directory on the server root called slideshow. However I would like to put this flash anim

  • Forms10g JAR and Java Plugin Caching problems

    Hello, Does anybody know following problem: We are deploying the forms java classes in a jar-file signed with our own certificate. We have a our own second (JavaBeans for forms) and a third jar file signed and deploying it in the right order archive

  • Business rules in HTML DB

    Dear developer of HTML DB HTML DB enables to represent many "Business Rules" in a so good format that I can show the edit pages of my application to business people as well. But I do not want to give them the possibility to edit my application. So I

  • Master table for SAP

    Hi, Can any one please let me know the standard SAP user table. Regards, lakshmi.