Forum Stats

  • 3,828,102 Users
  • 2,260,863 Discussions
  • 7,897,475 Comments

Discussions

NPE on updating components

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

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(SynthLookAndFeel.java:210)
	at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:266)
	at javax.swing.plaf.synth.SynthProgressBarUI.updateStyle(SynthProgressBarUI.java:59)
	at javax.swing.plaf.synth.SynthProgressBarUI.propertyChange(SynthProgressBarUI.java:318)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:318)
	at java.awt.Component.firePropertyChange(Component.java:8237)
	at javax.swing.JComponent.firePropertyChange(JComponent.java:4440)
	at javax.swing.JProgressBar.setIndeterminate(JProgressBar.java:918)
	at my.code.NotificationBar$3.run(NotificationBar.java:120)  // 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(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
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!
Tagged:

Answers

  • 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 http://bugs.sun.com/bugdatabase/
  • 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.