将Java外观与netbeans中的应用集成

时间:2013-05-23 14:24:28

标签: java swing netbeans look-and-feel synthetica

我使用netbeans

开发java程序

我在GUI应用程序中添加了一个外观和感觉,它是来自这个网站的Synthetica AluOxide外观:http://www.javasoft.de/synthetica/themes/

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

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

import de.javasoft.plaf.synthetica.SyntheticaAluOxideLookAndFeel;

。 。

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

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

  

线程中的异常" AWT-EventQueue-0"显示java.lang.NullPointerException     在   sun.font.FontDesignMetrics $ MetricsKey.init(FontDesignMetrics.java:217)     at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)     在   sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1003)     在javax.swing.JComponent.getFontMetrics(JComponent.java:1615)at   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)at   javax.swing.plaf.synth.SynthMenuUI.update(SynthMenuUI.java:248)at at   javax.swing.JComponent.paintComponent(JComponent.java:769)at   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)at   javax.swing.JComponent.paint(JComponent.java:1054)at   javax.swing.JLayeredPane.paint(JLayeredPane.java:585)at at   javax.swing.JComponent.paintChildren(JComponent.java:878)at   javax.swing.JComponent.paint(JComponent.java:1054)at   javax.swing.JComponent.paintToOffscreen(JComponent.java:5212)at   javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)     在javax.swing.RepaintManager.paint(RepaintManager.java:1236)at   javax.swing.JComponent._paintImmediately(JComponent.java:5160)at   javax.swing.JComponent.paintImmediately(JComponent.java:4971)at   javax.swing.RepaintManager $ 3.run(RepaintManager.java:796)at   javax.swing.RepaintManager $ 3.run(RepaintManager.java:784)at   java.security.AccessController.doPrivileged(Native Method)at   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)at   javax.swing.RepaintManager中的$ ProcessingRunnable.run(RepaintManager.java:1651)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)at   java.awt.EventQueue.access $ 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)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:697)at   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)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)   线程中的异常" AWT-EventQueue-0"显示java.lang.NullPointerException     在   sun.font.FontDesignMetrics $ MetricsKey.init(FontDesignMetrics.java:217)     at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)     在   sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1003)     在javax.swing.JComponent.getFontMetrics(JComponent.java:1615)at   sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:126)     在   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)at   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.paintToOffscreen(JComponent.java:5212)at   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)at   javax.swing.JComponent._paintImmediately(JComponent.java:5160)at   javax.swing.JComponent.paintImmediately(JComponent.java:4971)at   javax.swing.RepaintManager $ 3.run(RepaintManager.java:796)at   javax.swing.RepaintManager $ 3.run(RepaintManager.java:784)at   java.security.AccessController.doPrivileged(Native Method)at   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)at   javax.swing.RepaintManager中的$ ProcessingRunnable.run(RepaintManager.java:1651)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)at   java.awt.EventQueue.access $ 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)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:697)at   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)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

1 个答案:

答案 0 :(得分: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();
    }