Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8080628

No mnemonics on Open and Save buttons in JFileChooser

    Details

    • Subcomponent:
    • Resolved In Build:
      b68
    • Verification:
      Verified

      Backports

        Description

        Open and Save buttons are default buttons in JFileChooser dialog, therefore mnemonics are redundant.

        Mnemonics in JFileChooser were removed in Metal Look-and-Feel under JDK-7174970.
        Further, mnemonics were removed with the fix for JDK-8042835 from Asian locales (ja, ko, zh_CN, zh_TW) but then they were re-added by JDK-8059177.

        Steps to reproduce:

        1. Run SwingSet2: java -jar SwingSet2.jar
        2. Open JFileChooser demo, the fifth icon.
        3. Click Show Plain JFileChooser button. The should be no mnemonic on Open button in both cases where a file is selected and where a directory is selected.

        The test applies to all Look-and-Feels. In Windows LaF, you need to press and hold Alt button to see mnemonics.

        To change locale, pass -Duser.language possibly with -Duser.country. For example,

        java -Duser.language=es -jar SwingSet2.jar
        java -Duser.language=zh -Duser.country=CN -jar SwingSet2.jar

        Will launch SwingSet2 with Spanish and Chinese (China) UI language correspondingly. SwingSet is not localized but JFileChooser is.


        Alternatively, run the attached FileChooserMnemonics.java to get the list of mnemonic keys in different locales and Look-and-Feels. If there are no mnemonics, you'll see only the list of Look-and-Feels and locales that were tested – it is the expected result. If you see any key, for example "FileChooser.directoryOpenButtonMnemonic = 79" then localization resources need updating.

          Issue Links

            Activity

            Hide
            aivanov Alexey Ivanov added a comment - - edited
            Root cause:
            I believe basic.properties is used as translation base for other languages, thus mnemonics for Asian languages were returned with localization update in JDK-8059177.

            Metal L&F overrides the default values for Open and Save buttons, but does not override FileChooser.directoryOpenButton.textAndMnemonic. Thus, when a directory is selected in the file list, Open button displays mnemonic.

            The fix:
            Remove mnemonics from Open and Save buttons in JFileChooser in basic.properties.

            As the result of this, FileChooser.saveButton.textAndMnemonic and FileChooser.openButton.textAndMnemonic will be the same as in metal.properties, and they could be removed safely.
            Show
            aivanov Alexey Ivanov added a comment - - edited Root cause: I believe basic.properties is used as translation base for other languages, thus mnemonics for Asian languages were returned with localization update in JDK-8059177 . Metal L&F overrides the default values for Open and Save buttons, but does not override FileChooser.directoryOpenButton.textAndMnemonic. Thus, when a directory is selected in the file list, Open button displays mnemonic. The fix: Remove mnemonics from Open and Save buttons in JFileChooser in basic.properties. As the result of this, FileChooser.saveButton.textAndMnemonic and FileChooser.openButton.textAndMnemonic will be the same as in metal.properties, and they could be removed safely.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/8c5418750241
            User: aivanov
            Date: 2015-05-26 11:50:47 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/8c5418750241 User: aivanov Date: 2015-05-26 11:50:47 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/8c5418750241
            User: lana
            Date: 2015-06-10 21:24:34 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/8c5418750241 User: lana Date: 2015-06-10 21:24:34 +0000
            Hide
            dzhou Dora Zhou added a comment -
            Verified the regression-test: test/javax/swing/JFileChooser/8080628/bug8080628.java with JDK9 b134, passed.
            Show
            dzhou Dora Zhou added a comment - Verified the regression-test: test/javax/swing/JFileChooser/8080628/bug8080628.java with JDK9 b134, passed.

              People

              • Assignee:
                aivanov Alexey Ivanov
                Reporter:
                shadowbug Shadow Bug
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: