0

我正在使用 netbeans 开发一个 java 程序

我从这个网站为 GUI 应用程序添加了外观和感觉,即 Synthetica AluOxide Look and Feel:http ://www.javasoft.de/synthetica/themes/ 。

我使用我的项目库中的 Add Jar/Folder 对话框添加了 Synthetica.jar 和 synthetica.jar 和 syntheticaAluOxide.jar。

然后我将此代码添加到我的类加载中:

import de.javasoft.plaf.synthetica.SyntheticaAluOxideLookAndFeel;

. . .

try 
    {
      UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel());
    } 
    catch (Exception e) 
    {
      e.printStackTrace();
    }

但是当我运行我的应用程序时,我没有得到任何更改,并且当我单击应用程序中的某个组件时出现此错误:

sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286) 处 sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217) 处的线程“AWT-EventQueue-0”java.lang.NullPointerException 异常。 swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1003) 在 javax.swing.JComponent.getFontMetrics(JComponent.java:1615) 在 sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:125) 在 javax.swing.plaf.synth .SynthMenuItemLayoutHelper.(SynthMenuItemLayoutHelper.java:119) 在 javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498) 在 javax.swing.plaf.synth.SynthMenuUI.paint(SynthMenuUI.java:283) 在 javax .swing.plaf.synth.SynthMenuUI.update(SynthMenuUI.java:248) 在 javax.swing.JComponent.paintComponent(JComponent.java:769) 在 javax.swing。JComponent.paint(JComponent.java:1045) at javax.swing.JComponent.paintChildren(JComponent.java:878) at javax.swing.JComponent.paint(JComponent.java:1054) at javax.swing.JComponent.paintChildren(JComponent .java:878) 在 javax.swing.JComponent.paint(JComponent.java:1054) 在 javax.swing.JLayeredPane.paint(JLayeredPane.java:585) 在 javax.swing.JComponent.paintChildren(JComponent.java:878)在 javax.swing.JComponent.paint(JComponent.java:1054) 在 javax.swing.JComponent.paintToOffscreen(JComponent.java:5212) 在 javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295) 在 javax.swing。 RepaintManager.paint(RepaintManager.java:1236) 在 javax.swing.JComponent._paintImmediately(JComponent.java:5160) 在 javax.swing.JComponent.paintImmediately(JComponent.java:4971) 在 javax.swing.RepaintManager$3.run(RepaintManager.java:796) 在 javax.swing.RepaintManager$3.run(RepaintManager.java:784) 在 java.security.AccessController.doPrivileged(Native Method) 在 java.security .ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 在 javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:784) 在 javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:757) 在 javax.swing.RepaintManager.prePaintDirtyRegions (RepaintManager.java:706) 在 javax.swing.RepaintManager.access$1000(RepaintManager.java:62) 在 javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1651) 在 java.awt.event.InvocationEvent.dispatch (InvocationEvent.java:251) 在 java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727) 在 java.awt.EventQueue。访问 $200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:688) at java.awt.EventQueue$3.run(EventQueue.java:686) at java.security.AccessController.doPrivileged( Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:697) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 在 java.awt.EventDispatchThread .pumpEvents(EventDispatchThread.java:138) 在 java.awt.EventDispatchThread.run(EventDispatchThread.java:91) 在 sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286) 的 sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217) 的线程“AWT-EventQueue-0”java.lang.NullPointerException 中的异常sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1003) at javax.swing.JComponent.getFontMetrics(JComponent.java:1615) at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:126) at javax.swing.plaf .synth.SynthMenuItemLayoutHelper.(SynthMenuItemLayoutHelper.java:119) 在 javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498) 在 javax.swing.plaf.synth.SynthMenuItemUI.paint(SynthMenuItemUI.java:283)在 javax.swing.plaf.synth.SynthMenuItemUI.update(SynthMenuItemUI.java:247) 在 javax.swing.JComponent.paintComponent(JComponent.java:769) 在 javax.swing.JComponent.paint(JComponent.java:1045) 在 javax.swing.JComponent.paintChildren(JComponent.java:878) 在 javax.swing.JComponent.paint(JComponent.java:1054) 在 javax. swing.JComponent.paintToOffscreen(JComponent.java:5212) 在 javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1512) 在 javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1443) 在 javax.swing .BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:311) 在 javax.swing.RepaintManager.paint(RepaintManager.java:1236) 在 javax.swing.JComponent._paintImmediately(JComponent.java:5160) 在 javax.swing.JComponent.paintImmediately( JComponent.java:4971) 在 javax.swing.RepaintManager$3.run(RepaintManager.java:796) 在 javax.swing.RepaintManager$3.run(RepaintManager.java:784) 在 java.security.AccessController.doPrivileged(Native Method) 在 java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 在 javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:784) 在 javax。 swing.RepaintManager.paintDirtyRegions(RepaintManager.java:757) 在 javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:706) 在 javax.swing.RepaintManager.access$1000(RepaintManager.java:62) 在 javax.swing.RepaintManager$ ProcessingRunnable.run(RepaintManager.java:1651) at java.awt.EventQueue.dispatch(InvocationEvent.java:251) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727) at java.awt.EventQueue.access $200(EventQueue.java:103) 在 java.awt.EventQueue$3.run(EventQueue.java:688) 在 java.awt.EventQueue$3.run(EventQueue.java:686) 在 java.security.AccessController.doPrivileged(Native Method) 在 java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 在 java.awt.EventQueue.dispatchEvent(EventQueue.java:697) 在 java. awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) 在 java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 在 java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:146) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) 在 java.awt.EventDispatchThread.run(EventDispatchThread.java:91)doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:697) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java :161) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) 在 java .awt.EventDispatchThread.run(EventDispatchThread.java:91)doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:697) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java :161) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) 在 java .awt.EventDispatchThread.run(EventDispatchThread.java:91)pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java :138) 在 java.awt.EventDispatchThread.run(EventDispatchThread.java:91)pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java :138) 在 java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

4

1 回答 1

0

你是否包含了 Synthetica 的核心库 'synthetica.jar'

  1. 确保您的类路径包含所有 Synthetica 库(包括 Synthetica 的核心库“synthetica.jar”)。

  2. 在应用程序启动时启用 Synthetica 外观:

    import de.javasoft.plaf.synthetica.SyntheticaClassyLookAndFeel;
    
    
    try {
        UIManager.setLookAndFeel(new SyntheticaClassyLookAndFeel());
    } catch (Exception e) {
        e.printStackTrace();
    }
    
于 2013-05-24T05:35:31.930 回答