On 08/05/2011 05:00 PM, Pavel Porvatov wrote:
Hi Charles,
On 08/03/2011 08:49 PM, Pavel Porvatov wrote:
Hi Charles,
Yes, that's what I meant...
2. I do not think we should use VK_XXXX code. CR7024118 recommends
to remove the VK_XXX code right?
I don't see such recommendations. Anyway we cannot use chars now
because of backward compatibility requirement.
CR7024118 says:
"As seen in following, 3 mnemonic keys seems to be hardcoded and
making them unable to localize. Please consider externalizing them to
src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal.properties"
and
"Since following keys in
src/share/classes/com/sun/java/swing/plaf/motif/resources/motif_xx.properties
being translated, in some languages mnemonic character is not in
label string and won't show up in gui. "
It means the hardcoded VK_XXX codes can not be localized and in some
situation the mnemonic character is not shown in the label. So we
should use localized character as mnemonic. right?
The last your sentence is incorrect. Hardcoded mnemonics cannot be
localized via properties files and therefore they works only for for
English, but not for other supported languages. So we should use
localized VK_XXX as mnemonics... Because, as I said before, we MUST
keep backward compatibility.
Regards, Pavel
3. If the patch is ok, I would like to fix CR7024118 also.
So, there are two comments about the patch:
1. We must use VK_XXX codes for backward compatibility in WindowsLAF
and MetalLAFs . Therefore NimbusLAF should use VK_XXX codes as well
to be consistent with other LAFs
2. Could you please put mnemonics near labels? E.g.
FileChooser.lookInLabelText=Look In:
FileChooser.lookInLabelMnemonic=<VK_CODE>
It looks much more convenient I believe
Regards, Pavel
Hi Pavel,
I do not quite understand why we should keep VK_CODE, so I make two
patches for first review, I will modify other properties if one of the
patches is ok :-)
[1] is the patch which is not use VK_CODE. (attached)
[2] is the patch which is use VK_CODE, I have to use reflect in that
patch. Maybe I miss something. (attached)
--
Yours Charles
diff --git
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
index d222689..a52ceb3 100644
---
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
+++
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
@@ -19,10 +19,14 @@
############ FILE CHOOSER STRINGS #############
FileChooser.lookInLabelText=Look In:
+FileChooser.lookInLabelMnemonic=I
FileChooser.saveInLabelText=Save In:
FileChooser.fileNameLabelText=File Name:
+FileChooser.fileNameLabelMnemonic=N
FileChooser.folderNameLabelText=Folder name:
+FileChooser.folderNameLabelMnemonic=F
FileChooser.filesOfTypeLabelText=Files of Type:
+FileChooser.filesOfTypeLabelMnemonic=T
FileChooser.upFolderToolTipText=Up One Level
FileChooser.upFolderAccessibleName=Up
FileChooser.homeFolderToolTipText=Home
diff --git src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
index e971d9d..9362175 100644
--- src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
+++ src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
@@ -473,16 +473,16 @@ public class SynthFileChooserUIImpl extends
SynthFileChooserUI {
Locale l = fc.getLocale();
- lookInLabelMnemonic = getMnemonic("FileChooser.lookInLabelMnemonic",
l);
+ lookInLabelMnemonic =
(int)(UIManager.getString("FileChooser.lookInLabelMnemonic", l).charAt(0));
lookInLabelText = UIManager.getString("FileChooser.lookInLabelText",
l);
saveInLabelText = UIManager.getString("FileChooser.saveInLabelText",
l);
- fileNameLabelMnemonic =
getMnemonic("FileChooser.fileNameLabelMnemonic", l);
+ fileNameLabelMnemonic =
(int)(UIManager.getString("FileChooser.fileNameLabelMnemonic", l).charAt(0));
fileNameLabelText =
UIManager.getString("FileChooser.fileNameLabelText", l);
- folderNameLabelMnemonic =
getMnemonic("FileChooser.folderNameLabelMnemonic", l);
+ folderNameLabelMnemonic =
(int)(UIManager.getString("FileChooser.folderNameLabelMnemonic", l).charAt(0));
folderNameLabelText =
UIManager.getString("FileChooser.folderNameLabelText", l);
- filesOfTypeLabelMnemonic =
getMnemonic("FileChooser.filesOfTypeLabelMnemonic", l);
+ filesOfTypeLabelMnemonic =
(int)(UIManager.getString("FileChooser.filesOfTypeLabelMnemonic", l).charAt(0));
filesOfTypeLabelText =
UIManager.getString("FileChooser.filesOfTypeLabelText", l);
upFolderToolTipText =
UIManager.getString("FileChooser.upFolderToolTipText",l);
@@ -501,11 +501,6 @@ public class SynthFileChooserUIImpl extends
SynthFileChooserUI {
detailsViewButtonAccessibleName =
UIManager.getString("FileChooser.detailsViewButtonAccessibleName",l);
}
- private int getMnemonic(String key, Locale l) {
- return SwingUtilities2.getUIDefaultsInt(key, l);
- }
-
-
public String getFileName() {
if (fileNameTextField != null) {
return fileNameTextField.getText();
diff --git
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
index d222689..c375df3 100644
---
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
+++
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
@@ -19,10 +19,14 @@
############ FILE CHOOSER STRINGS #############
FileChooser.lookInLabelText=Look In:
+FileChooser.lookInLabelMnemonic=VK_I;
FileChooser.saveInLabelText=Save In:
FileChooser.fileNameLabelText=File Name:
+FileChooser.fileNameLabelMnemonic=VK_N
FileChooser.folderNameLabelText=Folder name:
+FileChooser.folderNameLabelMnemonic=VK_F
FileChooser.filesOfTypeLabelText=Files of Type:
+FileChooser.filesOfTypeLabelMnemonic=VK_T
FileChooser.upFolderToolTipText=Up One Level
FileChooser.upFolderAccessibleName=Up
FileChooser.homeFolderToolTipText=Home
diff --git src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
index e971d9d..9d86785 100644
--- src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
+++ src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
@@ -502,7 +502,12 @@ public class SynthFileChooserUIImpl extends
SynthFileChooserUI {
}
private int getMnemonic(String key, Locale l) {
- return SwingUtilities2.getUIDefaultsInt(key, l);
+ String vkCode = UIManager.getString(key, l);
+ try {
+ return KeyEvent.class.getField(vkCode).getInt(null);
+ } catch (Exception e) {
+ return 0;
+ }
}