2

我在设置 Java 中的物质外观时遇到问题。我的 PC 上安装了 JDK 1.8。我已经导入了这些 jar 文件:

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

当我运行我的程序时,它给了我一系列错误。这是我的代码:

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);
            }
        });
    }
}

这是我的错误列表:

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)
4

1 回答 1

0

不幸的是,Substance 多年来没有得到维护。尚未使用 JDK 8 尝试过,但可能存在一些迁移问题。

它有一个名为Insubstantial的分支,但听说该项目也在寻找新的维护者。太糟糕了,他们是很棒的库。

无论如何,这些都是开源库,所以如果你能找到问题并将其贡献给社区,那将是对社区的极大支持。

于 2014-05-16T06:25:07.687 回答