<Swing Dev> [12] Review request for 8187364: Unable to enter zero width non-joiner (ZWNJ) symbol in Swing text component

Anton Litvinov anton.litvinov at oracle.com
Fri Nov 2 22:32:59 UTC 2018


Hello,

Could you please review the following fix for the bug.

Bug: https://bugs.openjdk.java.net/browse/JDK-8187364
Webrev: http://cr.openjdk.java.net/~alitvinov/8187364/jdk12/webrev.00

The bug consists in the fact that on MS Windows OS with the enabled 
Persian keyboard layout zero width non-joiner (ZWNJ) character, whose 
Unicode code is "\u200C", cannot be entered in Swing text components by 
means of "Ctrl+Shift+2" key combination. The bug does not affect AWT 
text components.

CAUSE OF THE BUG:
In the method 
"javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction.actionPerformed(ActionEvent)" 
ZWNJ character "\u200C" is not inserted to the document of 
"javax.swing.JTextComponent" through the call 
"target.replaceSelection(content);", because a previous call to 
"sun.awt.SunToolkit.isPrintableCharacterModifiersMask(int)" method 
returns "false" for the case, when key modifiers integer variable equals 
3 ("Ctrl+Shift" keys are pressed).

THE FIX:
The fix changes the method 
"DefaultEditorKit.DefaultKeyTypedAction.actionPerformed(ActionEvent)" to 
allow entering 2 listed below Unicode characters in the text component's 
document, when these characters are treated as non-printable.
- "\u200C" - ZWNJ;
- "\u200D" - zero width joiner (ZWJ), which is entered by "Ctrl+Shift+1" 
key combination with Persian keyboard layout.

Thank you,
Anton


More information about the swing-dev mailing list