Debugging Question

R

RFleming

Hello, I am using Netbeans 5.5.1 on Windows XP SP2, JAVA 1.6.0_01,
jdk1.6.0_01, VM1.6.0_01-b06

I keep getting a flicker occasionally when I update a screen. (This
happens both in and out of the development) Recently I have left the
application running in netbeans and keep getting a stack trace that
occurs occasionally. The problem is that the stack trace refers to
classes written by SUN, so I have been unable as of now to track the
root cause. Below I have pasted the error and stack trace. I was
just wondering if anyone recognizes this, or can offer a suggestion to
tell the IDE to provide me with more data to help me solve the
problem.

Thanks in advance!

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
javax.swing.plaf.basic.BasicProgressBarUI.paint(BasicProgressBarUI.java:
391)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
at javax.swing.JComponent.paintComponent(JComponent.java:758)
at javax.swing.JComponent.paint(JComponent.java:1022)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:
5104)
at
javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:
285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent._paintImmediately(JComponent.java:
5052)
at javax.swing.JComponent.paintImmediately(JComponent.java:
4862)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:723)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)
at
javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:
659)
at javax.swing.SystemEventQueueUtilities
$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
273)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
183)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
173)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:
121)
 
R

RFleming

This *might* be the Swing/EDT problem.
Look into SwingWorker.invokeLater(Thread) method, &
<http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html>


Indeed that was the problem. I am somewhat new to JAVA, not
programming. I was forced to learn 'by fire' Java when another person
left the company, and I inherited a program, it did not use the
swing.invokelater for the progress bars, and they get updated twice a
second, which occaisonally caused stack trace errors, but the program
ran fine. I added the Swing.invokelater thread and the errors went
away.

Thanks for your assistance!


Ryan
 
L

Lew

This *might* be the Swing/EDT problem.
Look into SwingWorker.invokeLater(Thread) method, &
<http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html>


Indeed that was the problem. I am somewhat new to JAVA [sic],

It's spelled "Java".
not programming. I was forced to learn 'by fire' Java when another person
left the company, and I inherited a program, it did not use the
swing.invokelater for the progress bars, and they get updated twice a
second, which occaisonally caused stack trace errors, but the program
ran fine. I added the Swing.invokelater thread and the errors went
away.

The issue is thread concurrency. The EDT (Event Dispatch Thread) is supposed
to handle all graphic actions, and only graphic actions. Any other lengthy
work should run in a different thread.

SwingWorker.invokeLater() is a cover method for EventQueue.invokeLater() which
is a convenience method to invoke graphic actions on the EDT instead of on the
wrong thread.

Multi-threading means concurrency headaches. Study it in the Java tutorial
and in /Java Concurrency in Practice/, by Brian Goetz, et al.
 
A

Andrew Thompson

Indeed that was the problem.

You can chalk that answer up to Tom Hawtin, who
spent a considerable amount of time convincing me
that the use of invokeLater() was actually necessary.

( Oh, and Lew posted that link the other day - lucky
I was paying attention.. )
Thanks for your assistance!

I'll pass that on to Tom. ;-)

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
N

Nigel Wade

Indeed that was the problem. I am somewhat new to JAVA, not
programming. I was forced to learn 'by fire' Java when another person
left the company, and I inherited a program, it did not use the
swing.invokelater for the progress bars, and they get updated twice a
second, which occaisonally caused stack trace errors, but the program
ran fine. I added the Swing.invokelater thread and the errors went
away.

Thanks for your assistance!

If this application is a vital one, and you need to get it right, then it's
definitely worth you taking the time to read the Java/Swing Tutorial. There is
a section dedicated to progress bars, and also another on threads in Swing.
http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html

You might want to re-visit the code afterwards and verify that its use of
threads is valid given that you've already found one misuse.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top