Making the following call:
SwingUtilities.updateComponentTreeUI(comp);
which sporadically results in the following error :
Exception in thread "AWT-EventQueue-0"
java.lang.NullPointerException
at javax.swing.plaf.synth.SynthArrowButton$SynthArrowButtonUI.getPreferredSize(SynthArrowButton.java:106)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1662)
at javax.swing.plaf.basic.BasicScrollBarUI.layoutVScrollbar(BasicScrollBarUI.java:666)
at javax.swing.plaf.basic.BasicScrollBarUI.layoutContainer(BasicScrollBarUI.java:866)
at java.awt.Container.layout(Container.java:1511)
at java.awt.Container.doLayout(Container.java:1500)
at java.awt.Container.validateTree(Container.java:1696)
at java.awt.Container.validateTree(Container.java:1705)
at java.awt.Container.validateTree(Container.java:1705)
at java.awt.Container.validateTree(Container.java:1705)
at java.awt.Container.validate(Container.java:1631)
at javax.swing.RepaintManager$3.run(RepaintManager.java:711)
at javax.swing.RepaintManager$3.run(RepaintManager.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:708)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1731)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Apparently some component is becoming null. Added the following IF condition but it doesn't help :
if (comp != null)
SwingUtilities.updateComponentTreeUI(comp);
Going through the stack and it is purely a java stack and no reference to custom code. There are actually other NULL exception similar but referencing other Java objects.
Is there a way to iterate through the components in this tree to find which component is returning a null?