Azer Rtyu Azer Rtyu - 2 months ago 15
Java Question

Integrating Java Look And Feel into Application in netbeans

I'm devloping a java program using netbeans

I added a look and feel to GUI application which is Synthetica AluOxide Look and Feel from this website : http://www.javasoft.de/synthetica/themes/ .

I added the Synthetica.jar and syntheticaAluOxide.jar using Add Jar/Folder dialog o my project Libraries.

and then I added this code to my class load :

import de.javasoft.plaf.synthetica.SyntheticaAluOxideLookAndFeel;


.
.
.

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


but when I run my application I don't get any changes, and I get this error when I click on some component in my application :


Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)
at
sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1003)
at javax.swing.JComponent.getFontMetrics(JComponent.java:1615) at
sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:125)
at
javax.swing.plaf.synth.SynthMenuItemLayoutHelper.(SynthMenuItemLayoutHelper.java:119)
at
javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498)
at javax.swing.plaf.synth.SynthMenuUI.paint(SynthMenuUI.java:283) at
javax.swing.plaf.synth.SynthMenuUI.update(SynthMenuUI.java:248) 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
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)
at 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)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:784)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:757)
at
javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:706)
at 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)
at 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)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:697) at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.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)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)
at
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)
at
javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498)
at
javax.swing.plaf.synth.SynthMenuItemUI.paint(SynthMenuItemUI.java:283)
at
javax.swing.plaf.synth.SynthMenuItemUI.update(SynthMenuItemUI.java:247)
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.paintToOffscreen(JComponent.java:5212) at
javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1512)
at
javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1443)
at
javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:311)
at 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)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:784)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:757)
at
javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:706)
at 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)
at 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)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:697) at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at
java.awt.EventDispatchThread.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)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Answer

Did you include Synthetica's core library 'synthetica.jar'

  1. Ensure that your classpath contains all Synthetica libraries (including Synthetica's core library 'synthetica.jar').

  2. Enable the Synthetica Look and Feel at startup time in your application:

    import de.javasoft.plaf.synthetica.SyntheticaClassyLookAndFeel;
    
    
    try {
        UIManager.setLookAndFeel(new SyntheticaClassyLookAndFeel());
    } catch (Exception e) {
        e.printStackTrace();
    }
    
Comments