-
Bug
-
Resolution: Fixed
-
P2
-
1.1.6
-
1.2.2
-
x86
-
windows_nt
Customer has implemented the patch for bug id 4122687 but is having the
following problem:
We have implemented the java-level patch listed in bugtraq, and with
the patch in place we are able to successfully accept the AltGr characters.
However there is one character we are still unable to produce.
The '|' (pipe) character cannot be generated on a non-US keyboard within
Java when it is possible from other applications.
On a non-US keyboard this character should be generated by pressing
Alt + 0166 (via Numeric keypad).
TESTCASE:
Directions for running the testcase and the testcase source code are below:
1. Click on the language icon in the system tray. German is DE, English
is EN, French is FR. Select the one you want to activate.
This will switch keyboard layouts for the currently active window
(only). So, you could have several different languages activated in
several different windows at the same time.
2. It's very useful to have the character map application running,
so that you can see what characters require what special key
combinations. The character map application is in Start, Programs,
Accessories, System Tools, Character Map (in Win 98; it's slightly
different in Win95 and NT).
Highlighting a particular character will expand it and display the
key combination needed to generate the character. Be sure that you
have set the language for the character map application to the
desired language.
Key combination for German Pipe character is Alt + 0166 (Numeric keypad).
Below are other key combinations:
Desired Symbol Key combination
\ Control + Alt + -
@ Control + Alt + Q
superscript 2 Control + Alt + Shift + 2
superscript 3 Control + Alt + Shift + 3
[ Control + Alt + 9
] Control + Alt + 0
{ Control + Alt + 7
} Control + Alt +
/ Shift + 7
~ Control + Alt + ] (note that the character map incorrectly
indicates that this is produced using Control + Alt + +)
|
********************************************************************************
TESTCASE
********************************************************************************
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
public class AltGraphTest extends JFrame implements ActionListener {
JTextField textField;
JButton applyButton;
public AltGraphTest() {
setTitle(getClass().getName());
textField = new JTextField();
getContentPane().add(BorderLayout.NORTH, textField);
applyButton = new JButton("Apply Patch");
getContentPane().add(BorderLayout.SOUTH, applyButton);
applyButton.addActionListener(this);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src == applyButton) {
applyPatch();
applyButton.setEnabled(false); // only apply patch once
}
}
public static void main(String args[]) {
AltGraphTest agt = new AltGraphTest();
agt.pack();
agt.show();
}
// Recommended workaround for bug 4122687
public static void applyPatch() {
Keymap map = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
if (map != null) {
map.setDefaultAction(new DefaultKeyTypedAction());
} else {
System.err.println("Default keymap doesn't exist, patch not applied");
}
}
/**
* The action that is executed by default if
* a <em>key typed event</em> is received and there
* is no keymap entry. There is a variation across
* different VM's in what gets sent as a <em>key typed</em>
* event, and this action tries to filter out the undesired
* events. This filters the control characters and those
* with the ALT modifier.
* <p>
* If the event doesn't get filtered, it will try to insert
* content into the text editor. The content is fetched
* from the command string of the ActionEvent. The text
* entry is done through the <code>replaceSelection</code>
* method on the target text component. This is the
* action that will be fired for most text entry tasks.
*
* @see DefaultEditorKit#defaultKeyTypedAction
* @see DefaultEditorKit#getActions
* @see Keymap#setDefaultAction
* @see Keymap#getDefaultAction
*/
static class DefaultKeyTypedAction extends TextAction {
/**
* Creates this object with the appropriate identifier.
*/
public DefaultKeyTypedAction() {
super(DefaultEditorKit.defaultKeyTypedAction);
}
/**
* The operation to perform when this action is triggered.
*
* @param e the action event
*/
public void actionPerformed(ActionEvent e) {
JTextComponent target = getTextComponent(e);
if ((target != null) && (e != null)) {
String content = e.getActionCommand();
int mod = e.getModifiers();
if ((content != null) && (content.length() > 0) &&
(((mod & ActionEvent.ALT_MASK) == 0) ||
((mod & ActionEvent.CTRL_MASK) != 0))) {
char c = content.charAt(0);
if ((c >= 0x20) && (c != 0x7F)) {
target.replaceSelection(content);
}
}
}
}
}
}
following problem:
We have implemented the java-level patch listed in bugtraq, and with
the patch in place we are able to successfully accept the AltGr characters.
However there is one character we are still unable to produce.
The '|' (pipe) character cannot be generated on a non-US keyboard within
Java when it is possible from other applications.
On a non-US keyboard this character should be generated by pressing
Alt + 0166 (via Numeric keypad).
TESTCASE:
Directions for running the testcase and the testcase source code are below:
1. Click on the language icon in the system tray. German is DE, English
is EN, French is FR. Select the one you want to activate.
This will switch keyboard layouts for the currently active window
(only). So, you could have several different languages activated in
several different windows at the same time.
2. It's very useful to have the character map application running,
so that you can see what characters require what special key
combinations. The character map application is in Start, Programs,
Accessories, System Tools, Character Map (in Win 98; it's slightly
different in Win95 and NT).
Highlighting a particular character will expand it and display the
key combination needed to generate the character. Be sure that you
have set the language for the character map application to the
desired language.
Key combination for German Pipe character is Alt + 0166 (Numeric keypad).
Below are other key combinations:
Desired Symbol Key combination
\ Control + Alt + -
@ Control + Alt + Q
superscript 2 Control + Alt + Shift + 2
superscript 3 Control + Alt + Shift + 3
[ Control + Alt + 9
] Control + Alt + 0
{ Control + Alt + 7
} Control + Alt +
/ Shift + 7
~ Control + Alt + ] (note that the character map incorrectly
indicates that this is produced using Control + Alt + +)
|
********************************************************************************
TESTCASE
********************************************************************************
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
import com.sun.java.swing.text.*;
public class AltGraphTest extends JFrame implements ActionListener {
JTextField textField;
JButton applyButton;
public AltGraphTest() {
setTitle(getClass().getName());
textField = new JTextField();
getContentPane().add(BorderLayout.NORTH, textField);
applyButton = new JButton("Apply Patch");
getContentPane().add(BorderLayout.SOUTH, applyButton);
applyButton.addActionListener(this);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src == applyButton) {
applyPatch();
applyButton.setEnabled(false); // only apply patch once
}
}
public static void main(String args[]) {
AltGraphTest agt = new AltGraphTest();
agt.pack();
agt.show();
}
// Recommended workaround for bug 4122687
public static void applyPatch() {
Keymap map = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
if (map != null) {
map.setDefaultAction(new DefaultKeyTypedAction());
} else {
System.err.println("Default keymap doesn't exist, patch not applied");
}
}
/**
* The action that is executed by default if
* a <em>key typed event</em> is received and there
* is no keymap entry. There is a variation across
* different VM's in what gets sent as a <em>key typed</em>
* event, and this action tries to filter out the undesired
* events. This filters the control characters and those
* with the ALT modifier.
* <p>
* If the event doesn't get filtered, it will try to insert
* content into the text editor. The content is fetched
* from the command string of the ActionEvent. The text
* entry is done through the <code>replaceSelection</code>
* method on the target text component. This is the
* action that will be fired for most text entry tasks.
*
* @see DefaultEditorKit#defaultKeyTypedAction
* @see DefaultEditorKit#getActions
* @see Keymap#setDefaultAction
* @see Keymap#getDefaultAction
*/
static class DefaultKeyTypedAction extends TextAction {
/**
* Creates this object with the appropriate identifier.
*/
public DefaultKeyTypedAction() {
super(DefaultEditorKit.defaultKeyTypedAction);
}
/**
* The operation to perform when this action is triggered.
*
* @param e the action event
*/
public void actionPerformed(ActionEvent e) {
JTextComponent target = getTextComponent(e);
if ((target != null) && (e != null)) {
String content = e.getActionCommand();
int mod = e.getModifiers();
if ((content != null) && (content.length() > 0) &&
(((mod & ActionEvent.ALT_MASK) == 0) ||
((mod & ActionEvent.CTRL_MASK) != 0))) {
char c = content.charAt(0);
if ((c >= 0x20) && (c != 0x7F)) {
target.replaceSelection(content);
}
}
}
}
}
}
- relates to
-
JDK-4218892 Unable to enter '!' and '=A7' characters into AWT via the french =
- Resolved
-
JDK-4191924 JDK1.2 RC, German Windows NT 4.0: Awt TextField cannot input some=
- Resolved
-
JDK-4122687 AltGr keys are not working in Components (Swing, JBCL, AWT)
- Closed