JfileChooser ignoring special character folders on OS X

I have one Java program that browse the path of our local file system, for this we have used JFileChooser. If folder name is in simple English works fine on Windows, Mac OS X and Linux. But If I create folder named special character like - ábc Eóz then it shows that special character name on Windows and Linux only, but on OS X I am unable to see those special character folders. It ignore them from list of folders.

My program is built on java 7 update 21. Mac OS X version - 10.8.2

How can I solve this issue?

Thanks

UPDATE : We are creating an app for Mac using JavaFX packaging. When we are running app.jar directly, it showing me path containing special char. But if we are trying to launch application using app then it skipped that special char folders.

Answers


I just tried a sample:

import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;

public class Trial {
    public static void main(String... args) {
        JFrame frame = new JFrame("FrameDemo");

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel emptyLabel = new JLabel();

        frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

        frame.pack();

        frame.setVisible(true);

        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showOpenDialog(frame);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
            System.out.println("You chose to open this file: " +
                    chooser.getSelectedFile().getName());
        }
    }
}

on a OS X 10.9.1 running JDK 1.7.0_51. I created the following folders hierarchy: ~/Documents/Joyeux Naufragés/ábc Eóz: .

In order to address the problem you described I installed also the JDK you pointed out, JDK_1.7.0_25 and I managed to reproduce the same issue, here is the snapshot for the same window running u25

As one can see the folders containing special characters don't show. So I checked also with JDK 1.7.0_40 and surprise - it works. After that I went over the bugs fixed in the given version, I found out that several bugs related mac os x where fixed in this release. Among which a couple (7024118, 7032018, 7032436, 7161437) refer to issues in JFileChooser. There are other issues related to mac (45 in total) out of which one refers to FileDialog. Unfortunately the links to the bug descriptions don't work, so I cannot post more info on the subject, but the solution for your issue is definitely to update to at least version 1.7.0_40 even if I suppose the best would be to update to the latest (1.7.0_51).

Good luck with your work. I hope this helps you.


As we are building app using JavaFX packaging and we have our customized Info.plist kept inside ..buildscript_path/package/macosx/ folder at local path.

The problem of ignoring special characters get resolved by adding following keys to Info.plist.

 <key>LSEnvironment</key>
 <dict>
    <key>LANG</key>
    <string>en_US.UTF-8</string>
 </dict> 

On adding this line of code into info.plist, then building app solved my issue.

Thanks


Need Your Help

How can I reliably check client identity whilst making DCOM calls to a C# .NET 3.5 Server?

c# security .net-3.5 com-interop dcom

I have an old Win32 C++ DCOM Server that I am rewriting to use C# .NET 3.5. The client applications sit on remote Windows XP machines and are also written in C++. These clients must remain unchanged,

Clearing the test database between unit and functional tests in Rails (factory_girl)

ruby-on-rails ruby unit-testing factory-bot

Recently I switched from fixtures to factory_girl to test my Ruby on Rails application. If I run rake test:units, to run the tests in my /units directory, they all run perfectly. The same is true i...