创建 JSplitPane 时出现 java.lang.ClassCastException: javax.swing.KeyStroke
使用 JDK 1.5.0_08 初始化 JSplitPane
时,我遇到随机的不可重现的错误。 请注意,这种情况并非每次都会发生,但大约 80% 的时间都会发生:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.put(TreeMap.java:465)
at java.util.TreeSet.add(TreeSet.java:210)
at javax.swing.plaf.basic.BasicSplitPaneUI.installDefaults(BasicSplitPaneUI.java:364)
at javax.swing.plaf.basic.BasicSplitPaneUI.installUI(BasicSplitPaneUI.java:300)
at javax.swing.JComponent.setUI(JComponent.java:652)
at javax.swing.JSplitPane.setUI(JSplitPane.java:350)
at javax.swing.JSplitPane.updateUI(JSplitPane.java:378)
at javax.swing.JSplitPane.<init>(JSplitPane.java:332)
at javax.swing.JSplitPane.<init>(JSplitPane.java:287)
...
想法? 我尝试清理和重建我的项目,以尽量减少类文件损坏的可能性。
查看JDK-6434148:运行 SwingSet2 演示时抛出 ClassCastException,这似乎是是一个 JDK bug。 有什么已知的解决方法吗? 错误条目页面上没有列出任何内容。
I'm getting a random unreproducible Error when initializing a JSplitPane
in with JDK 1.5.0_08. Note that this does not occur every time, but about 80% of the time:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.put(TreeMap.java:465)
at java.util.TreeSet.add(TreeSet.java:210)
at javax.swing.plaf.basic.BasicSplitPaneUI.installDefaults(BasicSplitPaneUI.java:364)
at javax.swing.plaf.basic.BasicSplitPaneUI.installUI(BasicSplitPaneUI.java:300)
at javax.swing.JComponent.setUI(JComponent.java:652)
at javax.swing.JSplitPane.setUI(JSplitPane.java:350)
at javax.swing.JSplitPane.updateUI(JSplitPane.java:378)
at javax.swing.JSplitPane.<init>(JSplitPane.java:332)
at javax.swing.JSplitPane.<init>(JSplitPane.java:287)
...
Thoughts? I've tried cleaning and rebuilding my project so as to minimize the probability of corrupted class files.
Looking at JDK-6434148 : ClassCastException thrown while running SwingSet2 demo, this seems to be a JDK bug. Any known workarounds? None are listed on the bug entry page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Java Bug 数据库 中进行一些搜索后,这看起来可能是一个 JDK bug仅在 JDK 6 中修复。
请参阅JDK-6434148:运行 SwingSet2 演示时抛出 ClassCastException。
After doing some searching in the Java Bug Database, this looks like this might be a JDK bug that was only fixed in JDK 6.
See JDK-6434148 : ClassCastException thrown while running SwingSet2 demo.
当我升级 java 版本和 db Visualizer 并支持 jre7 时,抛出了同样的异常。 自从
适用于 Windows 和 Linux/UNIX 的 DbVisualizer 8.0 引入了对 Java 7 的支持。
DbVisualizer 9.1 中引入了对 Mac OS X 上的 Java 7 的支持。
所以对我有用的解决方案:
Windows/Unix/Linux:
在DbVisualizer安装目录中有一个.install4j目录,
在此目录中创建一个名为 pref_jre.cfg 的文件(如果尚不存在),
在文本编辑器中打开文件,
添加您要使用的 Java 安装的根目录的完整路径。
示例:C:\Program Files\Java\jre7
Same exception had got thrown when i had upgraded java verion and db visualizer dint support jre7. and since
Support for Java 7 was introduced in DbVisualizer 8.0 for Windows and Linux/UNIX.
Support for Java 7 on Mac OS X was introduced in DbVisualizer 9.1.
So Solution that worked for me :
Windows/Unix/Linux:
In the DbVisualizer installation directory there is an .install4j directory,
In this directory create a file named pref_jre.cfg if it doesn't already exist,
Open the file in a text editor,
Add the complete path to the root directory for the Java installation you want to use.
Example: C:\Program Files\Java\jre7
如果在 dbviz 中安装 java 7 后出现上述错误
然后添加环境变量,例如:
'DBVIS_JAVA_HOME' 作为'变量名'和java路径
例如。 “C:\SWDTOOLS\IBM\RAD85\runtimes\base_v7\java”
If you are getting above error after installing java 7 in dbviz
then add Environment variabbles like:
'DBVIS_JAVA_HOME' as a 'Variable Name' and java path like
for ex. "C:\SWDTOOLS\IBM\RAD85\runtimes\base_v7\java"