-
Bug
-
Resolution: Fixed
-
P3
-
5.0u1
-
None
-
b27
-
x86
-
windows_2000
-
Verified
According to the specs J2SE 1.4.2 and 5.0:
KeyboardFocusManager.setDefaultFocusTraversalKeys(int id, Set keystrokes)
"Throws: IllegalArgumentException - .. if any Object in
keystrokes is not an AWTKeyStroke"
However, the J2SE implementations 1.4.2 and 1.5.0 throw ClassCastException
instead of expected IllegalArgumentException.
The code sample below demonstrates the problem:
-------------- TestFT14.java -----------------
import java.awt.*;
import java.util.*;
public class TestFT14 {
KeyboardFocusManager currentKFM =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
public static void main(String[] args) {
new TestFT14().test();
}
private void test() {
AWTKeyStroke key = AWTKeyStroke.getAWTKeyStroke("ENTER");
HashSet set = new HashSet();
set.add(key);
set.add(new Object());
try {
currentKFM.setDefaultFocusTraversalKeys(
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
} catch(Exception e) {
if (e instanceof IllegalArgumentException) {
System.out.println("KFM: OKAY");
} else {
e.printStackTrace();
System.out.println("KFM: unexpected " + e + " thrown instead of IAE");
}
}
}
}
---------------------------------------------------
-------------- Output for 1.4.2 -------------------
e:\>c:\jdk1.4.2\bin\java -classpath . TestFT14
java.lang.ClassCastException
at java.awt.KeyboardFocusManager.setDefaultFocusTraversalKeys(KeyboardFocusManager.java:952)
at TestFT14.test(TestFT14.java:19)
at TestFT14.main(TestFT14.java:9)
KFM: unexpected java.lang.ClassCastException thrown instead of IAE
---------------------------------------------------
###@###.### 2004-11-16 11:06:39 GMT
KeyboardFocusManager.setDefaultFocusTraversalKeys(int id, Set keystrokes)
"Throws: IllegalArgumentException - .. if any Object in
keystrokes is not an AWTKeyStroke"
However, the J2SE implementations 1.4.2 and 1.5.0 throw ClassCastException
instead of expected IllegalArgumentException.
The code sample below demonstrates the problem:
-------------- TestFT14.java -----------------
import java.awt.*;
import java.util.*;
public class TestFT14 {
KeyboardFocusManager currentKFM =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
public static void main(String[] args) {
new TestFT14().test();
}
private void test() {
AWTKeyStroke key = AWTKeyStroke.getAWTKeyStroke("ENTER");
HashSet set = new HashSet();
set.add(key);
set.add(new Object());
try {
currentKFM.setDefaultFocusTraversalKeys(
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
} catch(Exception e) {
if (e instanceof IllegalArgumentException) {
System.out.println("KFM: OKAY");
} else {
e.printStackTrace();
System.out.println("KFM: unexpected " + e + " thrown instead of IAE");
}
}
}
}
---------------------------------------------------
-------------- Output for 1.4.2 -------------------
e:\>c:\jdk1.4.2\bin\java -classpath . TestFT14
java.lang.ClassCastException
at java.awt.KeyboardFocusManager.setDefaultFocusTraversalKeys(KeyboardFocusManager.java:952)
at TestFT14.test(TestFT14.java:19)
at TestFT14.main(TestFT14.java:9)
KFM: unexpected java.lang.ClassCastException thrown instead of IAE
---------------------------------------------------
###@###.### 2004-11-16 11:06:39 GMT
- relates to
-
JDK-6195828 Component.setFocusTraversalKeys(..) throws ClassCastException instead of IAE
-
- Closed
-