0

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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Unhandled Exception
  • 1,427
  • 14
  • 30
  • 1) See [What is a stack trace, and how can I use it to debug my application errors?](http://stackoverflow.com/q/3988788/418556) & [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/q/218384/418556) 2) For better help sooner, [edit] to add a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Feb 11 '19 at 21:07
  • I believe my choice for a title could have been better as it isn't a question about the null pointer but more in line with "How to iterate through the components in this tree to find which component is returning a null?" – Unhandled Exception Feb 12 '19 at 11:29
  • I didn't vote to close as a duplicate, just for not having a [mcve]. Post one as an [edit] & I'll consider voting to reopen, but at this stage, there's no good case for doing so. – Andrew Thompson Feb 12 '19 at 11:46
  • Unfortunately this issue is only visible within my environment which is why the question is more on how to iterate through object or rather what object(s) is Java looking at within JFrame so I can iterate through and explicitly narrow down which object is null. The original post should have been worded better. – Unhandled Exception Feb 12 '19 at 12:01

0 Answers0