物质外观和感觉不起作用

时间:2014-05-15 06:32:40

标签: java swing nullpointerexception look-and-feel substance

我在Java中遇到设置实质外观的问题。我的电脑上安装了JDK 1.8。我导入了这些jar文件:

  1. laf-widget-5.0.jar
  2. substance-6.0.jar
  3. trident.jar
  4. 当我运行我的程序时,它给了我一系列错误。这是我的代码:

    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)
    

1 个答案:

答案 0 :(得分:0)

不幸的是,物质多年来一直没有维持。没有尝试使用JDK 8,但可能存在一些迁移问题。

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

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