The SWING frame work that i am using is working fine with jre1.6.When i try to run it through jre1.7 getting the below exception .
java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to java.lang.Comparable
at java.util.TreeMap.compare(Unknown Source)
at java.util.TreeMap.put(Unknown Source)
at java.util.TreeSet.add(Unknown Source)
You know that a class cast can only cast an object to a type that it already is. If you look up KeyStroke, you find it doesn’t implement Comparable. I can tell that without looking in the API from the exception message you quoted. You may be able to sort by using the getKeyChar or getKeyCode methods, but I don’t know. You might have to use those methods inside the compare() method of a Comparator<KeyStroke>.