JDK7 Swing 导入皮肤出错找不到类·

caoliping 发布于 2012/03/25 10:48
阅读 1K+
收藏 1
 try {
             UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
         } catch (Exception e) {

   }

------------------------------------------------------------------------

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1871)
    at javax.swing.UIDefaults.getUIClass(UIDefaults.java:683)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:755)
    at javax.swing.UIManager.getUI(UIManager.java:1002)
    at javax.swing.JPanel.updateUI(JPanel.java:126)
    at javax.swing.JPanel.<init>(JPanel.java:86)
    at javax.swing.JPanel.<init>(JPanel.java:109)
    at javax.swing.JPanel.<init>(JPanel.java:117)
    at javax.swing.JRootPane.createGlassPane(JRootPane.java:545)
    at javax.swing.JRootPane.<init>(JRootPane.java:365)
    at javax.swing.JFrame.createRootPane(JFrame.java:277)
    at javax.swing.JFrame.frameInit(JFrame.java:258)
    at javax.swing.JFrame.<init>(JFrame.java:181)
    at com.cwy.swing.windowlogin.Longin.<init>(Longin.java:12)
    at com.cwy.swing.main.InitMain$1.run(InitMain.java:20)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.ClassNotFoundException: sun.swing.plaf.synth.SynthUI
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 43 more

加载中
0
liuex
liuex

从异常日志看,应该你是使用的com.seaglasslookandfeel.SeaGlassLookAndFeel,直接继承了sun.*的一个私有的LookAndFeel,但是在Java 7中,原先的许多sun.*的包名、类名都修改或删除了。以前我们项目中用到了sun.*中的FTP客户端,部署到JDK 7上面时也出现过类似的错误。。。

换成JDK1.6,或者修改com.seaglasslookandfeel.SeaGlassLookAndFeel的代码吧。

ps:sun的文档中n年前就说sun.*中的不是java规范中的,他们保留随时删除、修改的权利,并且不会做变更通知,但是sun一直没动手……

hantsy
hantsy
很多 SUN API是试验性,稳定之后会改成 java....包的。
0
leo-H
leo-H

这样试试:
LookAndFeel lnf = new  SeaGlassLookAndFeel();

 UIManager.setLookAndFeel(lnf); 

0
Monkey
Monkey
你导入 com.seaglasslookandfeel.SeaGlassLookAndFeel这个类所在的包吗?
0
Z-kc
Z-kc
这个好像用1.6就可以了,我遇到过这个错误
0
skft
skft
在jdk1.7中sun.swing.plaf.synth.SynthUI变成了javax.swing.plaf.synth.SynthUI
返回顶部
顶部