Results 1 to 11 of 11
  1. #1
    Astghik is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Default File chooser internationalization problem

    Hello All!

    I'm trying to have Armenian texts on Swing components.

    Java Code:
    Locale hay = new Locale("hy", "HY");
            Locale.setDefault(hay);
     
            UIManager.put("FileChooser.openDialogTitleText", "Բացել");
            UIManager.put("FileChooser.saveDialogTitleText", "Պահել");
            UIManager.put("FileChooser.lookInLabelText", "Փնտրել");
            UIManager.put("FileChooser.saveInLabelText", "Պահել");
            UIManager.put("FileChooser.upFolderToolTipText", "Մի Մակարդակ Վերև");
            UIManager.put("FileChooser.homeFolderToolTipText", "Աշխատաէկրան");
            UIManager.put("FileChooser.newFolderToolTipText", "Ստեղծել Նոր Պանակ");
            UIManager.put("FileChooser.listViewButtonToolTipText", "Ցուցակ");
            UIManager.put("FileChooser.detailsViewButtonToolTipText", "Մանրամասներ");
            UIManager.put("FileChooser.fileNameHeaderText", "Անուն");
            UIManager.put("FileChooser.fileSizeHeaderText", "Ծավալ");
            UIManager.put("FileChooser.fileTypeHeaderText", "Տեսակ");
            UIManager.put("FileChooser.fileDateHeaderText", "Փոփոխման Ամսաթիվ");
            UIManager.put("FileChooser.fileAttrHeaderText", "Հատկանիշներ");
            UIManager.put("FileChooser.fileNameLabelText", "Նշոցի Անուն");
            UIManager.put("FileChooser.filesOfTypeLabelText", "Նշոցների Տեսակներ");
            UIManager.put("FileChooser.openButtonText", "Բացել");
            UIManager.put("FileChooser.openButtonToolTipText", "Բացել Ընտրված Նշոցը");
            UIManager.put("FileChooser.saveButtonText", "Պահել");
            UIManager.put("FileChooser.saveButtonToolTipText", "Պահել Ընտրված Նշոցը");
            UIManager.put("FileChooser.directoryOpenButtonText", "Պահել");
            UIManager.put("FileChooser.directoryOpenButtonToolTipText", "Պահել Ընտրված Նշոցը");
            UIManager.put("FileChooser.cancelButtonText", "Դադարեցնել");
            UIManager.put("FileChooser.cancelButtonToolTipText", "Դադարեցնել Նշոց Ընտրման Երկխոսության Պատուհանը");
            UIManager.put("FileChooser.newFolderErrorText", "Նոր Պահոցի Ստեղծման Սխալ");
            UIManager.put("FileChooser.acceptAllFileFilterText", "Բոլոր Նշոցներ");
    Only DialogTitleText is working. And if I'm trying to internationalize other Swing components: buttons and so on, the only problem with JFrame title is.
    I'm working on WindowsXP, and java version is 1.6.0_17.

    Thanks in advance!
    Astghik

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default

    Did you do an updateUI() on your fileChooser? i.e.

    Java Code:
    chooser.updateUI();
    kind regards,

    Jos

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    What does the FileChooser look like with just the locale set to hy/HY when you start the JVM?

  4. #4
    Astghik is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Did you do an updateUI() on your fileChooser? i.e.

    Java Code:
    chooser.updateUI();
    kind regards,

    Jos
    chooser.updateUI(); doesn't work.

  5. #5
    Astghik is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by Steve11235 View Post
    What does the FileChooser look like with just the locale set to hy/HY when you start the JVM?

    see attached file
    Attached Thumbnails Attached Thumbnails File chooser internationalization problem-kkk.jpg  

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Astghik View Post
    chooser.updateUI(); doesn't work.
    It works for me but you have to call that method before you instantiate your JFileChooser. I saw your screendump: your font can't display those characters; you have a font problem not a localization problem.

    kind regards,

    Jos

  7. #7
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    Latest news: I have seen Armenian in Java!
    It exists in two fonts on my Windows installation:
    • Sylfaen
    • Arial Unicode MS

    I found these by checking all fonts with FontSelector.java,
    where I changed the sample string to include Armenian character in unicode escapes: \u0532\u0561\u0581
    The fonts themselves are in C:\Windows\Fonts, which is where I found the file name, ARIALUNI.TTF

    I changed the program code only to add: chooser.updateUI()
    (I also had to change the question marks from cut/paste into proper unicode escapes.)

    Finally I created the file .../jre/lib/fontconfig.properties
    and disabled the other fontconfig files by changing their names.
    I began by copying fontconfig.properties.src in the same directory.
    (It is attached, but the ".txt" in its name must be deleted.)
    To the file I added the following lines:
    • after each group of lines beginning dialogxxx.yyy I added a line: dialogxxx.yyy.unicode=Arial Unicode MS
    • to the end of the line beginning "sequence.fallback=" I added ",unicode
    • at the end of the file I added a line: "filename.Arial_Unicode_MS=ARIALUNI.TTF"



    --- older notes

    Armenian is not among the supported locales listed in Java SE Supported Locales.
    Could be a problem.
    But the code is using unicode escapes.
    And I get the same result whether or not I set the locale.

    chooser.updateUI() is essential.

    In Firefox I do see Aremenian characters. Attached.
    When I copy/paste into MSWord, I see the same.
    Attached Thumbnails Attached Thumbnails File chooser internationalization problem-armenian.png  
    Attached Files Attached Files

  8. #8
    Astghik is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Default

    I have sold in the following way!

    Java Code:
    public void setFileChooserFont(Component[] comp) {
            Font font = new Font("Sylfaen", Font.BOLD, 14);
            for (int x = 0; x < comp.length; x++) {
                if (comp[x] instanceof Container) {
                    setFileChooserFont(((Container) comp[x]).getComponents());
                }
                comp[x].setFont(font);
            }
        }
    Java Code:
    JFileChooser fc = new JFileChooser();
     setFileChooserFont(fc.getComponents());
    I appreciate your help very much!!
    Thank you!!
    Astghik

  9. #9
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    So it was a font issue? Looking at the screen shot, it appeared that the character set had changed but the font didn't support it. My question is, did changing the locale cause the text to change to hy?

  10. #10
    Astghik is offline Member
    Join Date
    Jan 2010
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by Steve11235 View Post
    So it was a font issue? Looking at the screen shot, it appeared that the character set had changed but the font didn't support it. My question is, did changing the locale cause the text to change to hy?
    No.

    At the first time I've tried UIManager.put("FileChooser.font", font);

    But it didn't work.

    Still I don't understand the reasons of my problem.

  11. #11
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    UIManager.put("FileChooser.font", font);
    This cannot work; JFileChooser does not look for a FileChooser.font property.
    JFileChooser--and all other widgets--use the standard logical font called "Dialog".
    And the physical font usually assigned to the Dialog font does not have glyphs for the Armenian characters.

    The changes that I gave for the fontconfig.properties file will fix ALL widgets so they will display Armenian.
    It will fix other characters in many languages that are in the Arial Unicode font.
    And without affecting existing applications.
    I continue to use the revised fontconfig.properties file on my home system
    because it will let me see more characters correctly.

    {The setFileChooserFont() kludge that "sold" [solved] the problem above
    will change the fonts only for that one instance of JFileChooser.
    And it gets it wrong by changing some bold fonts to plain.
    Why is it that some programmers will reject a 100% solution with no programming
    in favor of a 7% solution that is done with coding but leaves the underlying problem festering?}

Similar Threads

  1. Color Chooser Demo
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 08:48 PM
  2. [SOLVED] File chooser selecting file from directory...?
    By prabhurangan in forum AWT / Swing
    Replies: 12
    Last Post: 06-18-2008, 05:08 AM
  3. Using File Chooser
    By shaungoater in forum New To Java
    Replies: 0
    Last Post: 03-20-2008, 01:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •