Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exception in at javax.swing.SwingGraphics.createSwingGraphics

0 views
Skip to first unread message

job...@hotmail.com

unread,
Jul 19, 2005, 2:41:21 PM7/19/05
to
I am getting the following exception sometimes in my GUI. How can I
debug this? There is nothing from my code in the stack and the
exception is not easily reproducible. Any help will be greatly
appreciated.

java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1064)
at
javax.swing.SwingGraphics.createSwingGraphics(SwingGraphics.java:147)
at javax.swing.JComponent._paintImmediately(JComponent.java:4670)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.NullPointerException
at javax.swing.JComponent._paintImmediately(JComponent.java:4671)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
In paintImmediately null graphics

Mathias Lichtner

unread,
Jul 19, 2005, 3:24:47 PM7/19/05
to
job...@hotmail.com wrote:
> I am getting the following exception sometimes in my GUI. How can I
> debug this? There is nothing from my code in the stack and the
> exception is not easily reproducible. Any help will be greatly
> appreciated.
>

[...]


> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
> In paintImmediately null graphics
>

last line, 'In paintImmediately null graphics', perhaps you have
modified your 'Graphics' in an overridden method like paintComponent
or modified it somewhere else?

hiwa

unread,
Jul 19, 2005, 6:38:54 PM7/19/05
to
job...@hotmail.com wrote in message news:<1121798481.0...@g47g2000cwa.googlegroups.com>...

> I am getting the following exception sometimes in my GUI. How can I
> debug this? There is nothing from my code in the stack and the
> exception is not easily reproducible. Any help will be greatly
> appreciated.
>
> java.lang.Exception: Stack trace
> at java.lang.Thread.dumpStack(Thread.java:1064)
> at
> javax.swing.SwingGraphics.createSwingGraphics(SwingGraphics.java:147)
> at javax.swing.JComponent._paintImmediately(JComponent.java:4670)
> at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
> at
> javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
> at
> javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
javax.swing.SwingGraphics?
What is it?

Thomas Hawtin

unread,
Jul 19, 2005, 7:02:26 PM7/19/05
to
hiwa wrote:
> job...@hotmail.com wrote in message news:<1121798481.0...@g47g2000cwa.googlegroups.com>...
>
>>I am getting the following exception sometimes in my GUI. How can I
>>debug this? There is nothing from my code in the stack and the
>>exception is not easily reproducible. Any help will be greatly
>>appreciated.
>>
>>java.lang.Exception: Stack trace
>> at java.lang.Thread.dumpStack(Thread.java:1064)
>> at
>>javax.swing.SwingGraphics.createSwingGraphics(SwingGraphics.java:147)
>> at javax.swing.JComponent._paintImmediately(JComponent.java:4670)
>> at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
>> at
>>javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
>> at
>>javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
>> at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
>> at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
>
> javax.swing.SwingGraphics?
> What is it?

It's an old non-public implementation class. We can deduce that hiwa is
not using Java 5.0.

Looks like a getGraphics is returning null at a guess. That would mean
trying to paint a Component that isn't displayed.

A quick search of the bug parade brings up

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5004059
"JComponent.paintImmediately() always prints stack trace for NPE"

The title refers to the two stack traces presented in the initial
posing. Last evaluation says

"It was determined this exception is stemming from customer removing a
component from the containment hierarchy on another thread, something we
don't allow. Customer will be fixing their application. None-the-less
JComponent should not being eating this exception and we will change that."

So, is the original poster breaking Swing's threading rules? The stack
trace with line numbers is all very nice, but which version does this
correspond to? Any chance of more details, such as a small,
demonstrating example?

Tom Hawtin
--
Unemployed English Java programmer

Thomas Fritsch

unread,
Jul 19, 2005, 8:19:55 PM7/19/05
to
<job...@hotmail.com> schrieb im Newsbeitrag
news:1121798481.0...@g47g2000cwa.googlegroups.com...

>I am getting the following exception sometimes in my GUI. How can I
> debug this? There is nothing from my code in the stack and the
> exception is not easily reproducible. Any help will be greatly
> appreciated.
>
> java.lang.Exception: Stack trace
> at java.lang.Thread.dumpStack(Thread.java:1064)
> at javax.swing.SwingGraphics.createSwingGraphics(SwingGraphics.java:147)
> at javax.swing.JComponent._paintImmediately(JComponent.java:4670)
> ...

Take a look at the source (in "src.zip" of your JDK installation) of
Thread.dumpStack()
/**
* Prints a stack trace of the current thread. This method is used
* only for debugging.
*/
public static void dumpStack() {
new Exception("Stack trace").printStackTrace();
}
You see, that the Exception is *not* thrown. It is just created to print a
stack trace, and the method returns normally. (May be some developer of the
SwingGraphics class has "forgotten" to remove a debugging line
"Thread.dumpStack();" before that JDK version was released.) So there is no
problem at all, and you can safely ignore it.

Of course, in your IDE-debugger you could set a breakpoint on
Thread.dumpStack() to see under which circumstances it happens. But I think
it is not worth the effort.

--
"TFritsch$t-online:de".replace(':','.').replace('$','@')


0 new messages