我正在使用BorderFactory用主题为Substance UI的Swing用户界面创建带标题的边框,并且遇到了以下所示的异常。我尝试了LineBorder,它可以正常工作,但是Substance UI似乎在某种程度上干扰了TitledBorder。边框绘制通过paintComponent通过以下方式完成:

if (getBorder() != null) {
   getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
}

这本身可能是不正确的。我的问题本质上是如何在不创建父TitledBorder并将其设置为其的情况下使JPanel工作,这似乎有点不合时宜。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.pushingpixels.lafwidget.utils.RenderingUtils.desktopHints(RenderingUtils.java:113)
    at org.pushingpixels.lafwidget.utils.RenderingUtils.installDesktopHints(RenderingUtils.java:85)
    at org.pushingpixels.substance.internal.utils.border.SubstanceEtchedBorder.paintBorder(SubstanceEtchedBorder.java:132)
    at javax.swing.border.TitledBorder.paintBorder(TitledBorder.java:330)
    at javax.swing.JComponent.paintBorder(JComponent.java:947)
    at javax.swing.JComponent.paint(JComponent.java:1055)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paint(JComponent.java:1063)
    at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
    at javax.swing.JComponent.paintChildren(JComponent.java:887)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5213)
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1493)
    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1424)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1217)
    at javax.swing.JComponent.paint(JComponent.java:1040)
    at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
    at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
    at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
    at java.awt.Container.paint(Container.java:1951)
    at java.awt.Window.paint(Window.java:3814)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:792)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:739)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:688)
    at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1632)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:660)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

在此先感谢您的帮助。

最佳答案

这是拉夫小部件深处的错误。当前假定每个Graphics对象都有一个GraphicsConfiguration和与之关联的GraphicsDevice。我有一个叫做insubstantial的物质叉子,就是这个has a fix

固定在其中的当前快照的Maven坐标为com.github.insubstantial:substance:6.3-SNAPSHOT,快照存储库位于https://oss.sonatype.org/content/repositories/snapshots/。我预计将在6月底或前后发布6.3版火车。

07-28 07:30