Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Debugging Question

Thread view: 
RFleming@NationalSteel.com - 12 Sep 2007 18:57 GMT
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)
Andrew Thompson - 12 Sep 2007 23:23 GMT
...
>I keep getting a flicker occasionally when I update a screen.  
...
>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

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

Signature

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

RFleming@NationalSteel.com - 13 Sep 2007 23:20 GMT
> 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
Lew - 14 Sep 2007 03:09 GMT
>> 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.

Signature

Lew

Roedy Green - 14 Sep 2007 03:47 GMT
>SwingWorker.invokeLater()

see http://mindprod.com/jgloss/swingthreads.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Andrew Thompson - 14 Sep 2007 08:17 GMT
>> 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.  

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.  ;-)

Signature

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

Nigel Wade - 14 Sep 2007 15:21 GMT
>> This *might* be the Swing/EDT problem.
>> Look into SwingWorker.invokeLater(Thread) method, &
[quoted text clipped - 9 lines]
>
> 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.

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Roedy Green - 13 Sep 2007 01:18 GMT
>javax.swing.plaf.basic.BasicProgressBarUI.paint(BasicProgressBarUI.java:

Looks like it has something to do with a progress bar. See
http://mindprod.com/jgloss/progress.html

Put some asserts near all your progress stuff to ensure all is kosher.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 13 Sep 2007 02:16 GMT
>> javax.swing.plaf.basic.BasicProgressBarUI.paint(BasicProgressBarUI.java:
>
> Looks like it has something to do with a progress bar. See
> http://mindprod.com/jgloss/progress.html
>
> Put some asserts near all your progress stuff to ensure all is kosher.

Make sure that what you assert are program invariants, not data validation.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.