Substance look and feel not working

1.6k views Asked by At

I'm having problem setting substance look n feel in Java. I have JDK 1.8 installed on my PC. i have imported these jar files:

  1. laf-widget-5.0.jar
  2. substance-6.0.jar
  3. trident.jar

When I run my program, it gives me a series of errors. Here's my code:

import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.*;

import org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel;

public class Walkthrough extends JFrame {
    public Walkthrough() {
        super("Sample app");
        this.setLayout(new FlowLayout());
        this.add(new JButton("button"));
        this.add(new JCheckBox("check"));
        this.add(new JLabel("label"));

        this.setSize(new Dimension(250, 80));
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(new SubstanceGraphiteLookAndFeel());
                } catch (Exception e) {
                    System.out.println("Substance Graphite failed to initialize");
                }
                Walkthrough w = new Walkthrough();
                w.setVisible(true);
            }
        });
    }
}

And here is my error list:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getDefaultBackgroundColor(SubstanceColorUtilities.java:823)
    at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getBackgroundFillColor(SubstanceColorUtilities.java:726)
    at org.pushingpixels.substance.internal.ui.SubstancePanelUI.installDefaults(SubstancePanelUI.java:73)
    at javax.swing.plaf.basic.BasicPanelUI.installUI(Unknown Source)
    at javax.swing.JComponent.setUI(Unknown Source)
    at javax.swing.JPanel.setUI(Unknown Source)
    at javax.swing.JPanel.updateUI(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JRootPane.createGlassPane(Unknown Source)
    at javax.swing.JRootPane.<init>(Unknown Source)
    at javax.swing.JFrame.createRootPane(Unknown Source)
    at javax.swing.JFrame.frameInit(Unknown Source)
    at javax.swing.JFrame.<init>(Unknown Source)
    at substanceLookNFeel.Walkthrough.<init>(Walkthrough.java:11)
    at substanceLookNFeel.Walkthrough$1.run(Walkthrough.java:31)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$400(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)
1

There are 1 answers

0
rlegendi On

Unfortunately, Substance is not maintained for years. Haven't tried it with JDK 8 but there might be some migration issues.

It had a fork called Insubstantial but heard that the project is looking for a new maintainer too. Too bad, awesome libs they were.

Anyway, these are open source libraries so if you can hunt down the issue and contribute it to the community, it would be a really great support for the community.