kirill-grouchnikov / substance

A modern and high-performant Swing look-and-feel library
163 stars 109 forks source link

NPE in SubstanceColorUtilities.getBackgroundFillColor #3

Closed klbsjpolp closed 7 years ago

klbsjpolp commented 13 years ago

I'm using a third-party check box component who calls print in its updateUI method to extract some info on the rendering. The problem is that the component must be painted but is not already on a hierarchy. SubstanceColorUtilities.getBackgroundFillColor() takes the parent component to get the background color but doesn't check if the parent is not null.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.pushingpixels.substance.internal.utils.SubstanceColorUtilities.getBackgroundFillColor(SubstanceColorUtilities.java:689) at org.pushingpixels.substance.internal.painter.BackgroundPaintingUtils.update(BackgroundPaintingUtils.java:122) at org.pushingpixels.substance.internal.ui.SubstanceRadioButtonUI.paint(SubstanceRadioButtonUI.java:324) at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143) at org.pushingpixels.substance.internal.ui.SubstanceRadioButtonUI.orgpushingpixelssubstanceinternaluiSubstanceRadioButtonUIupdate(SubstanceRadioButtonUI.java) at org.pushingpixels.substance.internal.ui.SubstanceRadioButtonUI.update(SubstanceRadioButtonUI.java) at org.pushingpixels.substance.internal.ui.SubstanceCheckBoxUI.orgpushingpixelssubstanceinternaluiSubstanceCheckBoxUIupdate(SubstanceCheckBoxUI.java) at org.pushingpixels.substance.internal.ui.SubstanceCheckBoxUI.update(SubstanceCheckBoxUI.java) at javax.swing.JComponent.paintComponent(JComponent.java:752) at javax.swing.JComponent.printComponent(JComponent.java:1193) at javax.swing.JComponent.paint(JComponent.java:1033) at javax.swing.JComponent.print(JComponent.java:1175) at chrriis.dj.swingsuite.JTriStateCheckBox.findIndeterminateColor(JTriStateCheckBox.java:328) at chrriis.dj.swingsuite.JTriStateCheckBox.updateUI(JTriStateCheckBox.java:302) at javax.swing.AbstractButton.init(AbstractButton.java:2149) at javax.swing.JToggleButton.(JToggleButton.java:159) at javax.swing.JCheckBox.(JCheckBox.java:157) at javax.swing.JCheckBox.(JCheckBox.java:109) at chrriis.dj.swingsuite.JTriStateCheckBox.(JTriStateCheckBox.java:147) at ctec.sdk.uiUtil.component.CTTristateCheckBox$2.run(CTTristateCheckBox.java:54) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

shemnon commented 13 years ago

I've seen this several times at my day job too. I'll look into the patch we have and possibly post it to my fork.

shemnon commented 13 years ago

There is a fix for this in my 'insubstantial' branch of substance, specifically these two diffs: d83acf83992ca22b8b0f8b59e50170cb6178f7f3 and f56e9464ceb7472f3e4116c35d65e6388ef4950e

kirill-grouchnikov commented 7 years ago

Please reopen if this is still happening under the latest dev builds with complete, small and standalone sample that reproduces this issue.