-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.1.8
-
sparc
-
solaris_2.5
Name: bkR10101 Date: 01/23/2001
This bug is filed only for tracking purposes, the fix has already been
integrated in jdk1.2, so feel free to close it as such.;
The excerpt from the spec for java.awt.event.KeyEvent class:
"
...
public static final int VK_UNDEFINED
KEY_TYPED events do not have a defined keyCode.
...
public static final char CHAR_UNDEFINED
KEY_PRESSED and KEY_RELEASED events which do
not map to a valid Unicode character do not
have a defined keyChar.
....
".
So, it is possible to create a KeyEvent object via
calling to
KeyEvent(some_correct_component,
KeyEvent.KEY_TYPED,
some_correct_long,
some_correct_int, KeyEvent.VK_UNDEFINED)
constructor.
Nevertheless, this constructor will throw IllegalArgumentException
_always_ in jdk 1.1.8. Below the piece from jdk 1.1.8 source for
java.awt.event.KeyEvent:
"
...
public static final int VK_UNDEFINED = 0x0;
...
public static final char CHAR_UNDEFINED = 0x0;
...
public KeyEvent(Component source, int id, long when, int modifiers,
int keyCode, char keyChar) {
super(source, id, when, modifiers);
if (id == KEY_TYPED && keyChar == CHAR_UNDEFINED) {
throw new IllegalArgumentException("invalid keyChar");
}
...
}
...
public KeyEvent(Component source, int id, long when, int modifiers,
int keyCode) {
this(source, id, when, modifiers, keyCode, (char)keyCode);
// (char)keyCode equals to VK_UNDEFINED equals to 0x0
}
"
======================================================================