简体   繁体   English

Java-无法应用Java外观

[英]Java- Can't apply Java Look and Feel

I'm using Synthetica Look and Feel in my application and it works fine on Eclipse. 我在应用程序中使用Synthetica外观,并且在Eclipse上运行良好。 But when i export the Jar file and execute it i got these errors : 但是当我导出Jar文件并执行它时,出现以下错误:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI
at de.javasoft.plaf.synthetica.SyntheticaDefaultLookup.getDefault(SyntheticaDefaultLookup.java:105)
at sun.swing.DefaultLookup.get(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.getInputMap(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.installKeyboardActions(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.installKeyboardActions(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.AbstractButton.setUI(Unknown Source)
at javax.swing.JButton.updateUI(Unknown Source)
at javax.swing.AbstractButton.init(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel.installCompatibilityDefaults(SyntheticaLookAndFeel.java:925)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel$4.propertyChange(SyntheticaLookAndFeel.java:582)
at java.beans.PropertyChangeSupport.fire(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.UIManager.setLookAndFeel(Unknown Source)
at com.evaluator.MainWindow.<init>(MainWindow.java:85)
at com.evaluator.Main$1.run(Main.java:15)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
   Caused by: java.lang.ClassNotFoundException: sun.swing.plaf.synth.SynthUI
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 35 more

I don't know where is the problem exactly. 我不知道问题出在哪里。 Here is the way I'm applying the Synthetica Blue Steel Look And Feel : 这是我应用Synthetica Blue Steel外观的方式:

try 
    {
      UIManager.setLookAndFeel(new SyntheticaBlueSteelLookAndFeel());
      UIManager.put("Synthetica.rootPane.titlePane.title.center", true);
      UIManager.put("Synthetica.translucency4DisabledIcons.enabled", true); 

    } 
    catch (Exception e) {}

Please see the error it can't find the sun/swing/plaf/synth/SynthUI Library. 请查看找不到sun / swing / plaf / synth / SynthUI库的错误。 In development mode You are include that jar file in eclipse library but when you are create a jar file then you are not include the Synthui theme jar. 在开发模式中,您将那个jar文件包含在eclipse库中,但是当您创建一个jar文件时,您将不包含Synthui主题jar。 Put that Synthui jar file in jar, ext/ folder and it work fine 将该Synthui jar文件放在jar,ext /文件夹中,即可正常工作

I think the way you are exporting the jar file is not correct. 我认为您导出jar文件的方式不正确。

Try exporting the jar as a Runnable jar file. 尝试将罐子导出为可运行的罐子文件。
Follow these steps to export your app as a runnable jar. 请按照以下步骤将应用程序导出为可运行的jar。
1) select export from the file menu. 1)从文件菜单中选择导出。
2) select Java->Runnable JAR file 2)选择Java-> Runnable JAR文件
3) Select the launch configuration ie your main class. 3)选择启动配置,即您的主类。
4) first two option of library handling if you want to package the substance library file in your own jar and the third option(copy required library into a sub folder next to the generated jar) if you want to separate the generated jar file and substance libs. 4)如果要将物质库文件打包在自己的jar中,则使用库处理的前两个选项;如果要将生成的jar文件和物质分开,则使用第三个选项(将所需的库复制到生成的jar旁边的子文件夹中)库。
5)Press finish. 5)按完成。

I hope this would solve your problem. 我希望这可以解决您的问题。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM