Forum Stats

  • 3,828,102 Users
  • 2,260,863 Discussions


NPE on updating components

egarcia_sms Member Posts: 6
edited Dec 17, 2010 5:42AM in Swing

I'm doing an applet using Swing. I've set Nimbus LAF first think in init() and called SwingUtilities.updateComponentTreeUI() just in case.

I have a JProgressBar that I update during a long calculation. My long calculation is done on the doBackground() of the SwingWorker. I call a method to set the JProgressBar indeterminate, maximum, minimum and progress values. All those methods are called using SwingUtilities.invokeLater(). All of them work fine EXCEPT setIndeterminate(), that throws the following NPE.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at javax.swing.plaf.synth.SynthLookAndFeel.getStyle(
	at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(
	at javax.swing.plaf.synth.SynthProgressBarUI.updateStyle(
	at javax.swing.plaf.synth.SynthProgressBarUI.propertyChange(
	at java.beans.PropertyChangeSupport.firePropertyChange(
	at java.beans.PropertyChangeSupport.firePropertyChange(
	at java.beans.PropertyChangeSupport.firePropertyChange(
	at java.awt.Component.firePropertyChange(
	at javax.swing.JComponent.firePropertyChange(
	at javax.swing.JProgressBar.setIndeterminate(
	at my.code.NotificationBar$  // My own runnable that calls invokeLater() if we're not on EDT and only has the line bar.setIndeterminate(true/false)
	at java.awt.event.InvocationEvent.dispatch(
	at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(
Change really occurs, and I can see the bar turning indeterminate, but I don't like having unknowns exceptions being thrown in my code.

Anyone have any idea?

Thanks a lot in advance!


  • walterln
    walterln Member Posts: 2,302
    You do set the L&F on the EDT as well in init() right? If yes then it sounds like a bug when using Nimbus in an Applet. So make a standalone applet that reproduces it and report at
  • Of course, I set the LAF in the EDT. I've modified it and added the code to run on the EDT to my constructor just in case something is calling first a Swing component and the LAF is being set before I set the LAF (but that's what SwingUtilities.updateComponentTreeUI() is for, isn't it?) but it made no differences.

    Thanks a lot for your response, I'll be testing a little bit more and I'll try to make a standalone app that reproduces the problem.
This discussion has been closed.