I'm using BorderFactory
to create a titled border with a Substance UI themed Swing user interface, and I'm coming across the exception shown below. I tried with LineBorder
and it works perfectly, but it appears that Substance UI is interfering somehow with TitledBorder
. The border drawing is done in paintComponent
via:
if (getBorder() != null) {
getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
}
which itself may be incorrect. My question is essentially how to get TitledBorder
working without creating a parent JPanel
and setting it on that instead, which seems like a bit of a cop-out.
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)
Thanks in advance for any help.
This is a bug deep in the bowels of laf-widget. It currently assumes that every Graphics object has a GraphicsConfiguration and a GraphicsDevice associated with it. I have a fork of substance called insubstantial that has a fix for this.
The maven coordinates for the current snapshot this is fixed in are com.github.insubstantial:substance:6.3-SNAPSHOT and the snapshot repository is at https://oss.sonatype.org/content/repositories/snapshots/. I anticipate releasing the 6.3 train at or around the end of June.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With