JDK-8080628 : No mnemonics on Open and Save buttons in JFileChooser
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-05-18
  • Updated: 2017-01-11
  • Resolved: 2015-05-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u60Fixed 9 b68Fixed openjdk7uFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
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.
Comments
Verified the regression-test: test/javax/swing/JFileChooser/8080628/bug8080628.java with JDK9 b134, passed.
05-09-2016

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.
21-05-2015