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 / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

Exception in thread "AWT-EventQueue

Thread view: 
patrick - 20 Aug 2005 22:55 GMT
Ive got a swing application with quite a lot of code. With several JFrames
being created at various stages.
Its working fine but sometimes Im getting a ClassCastException ,copied
below, at no
predictable time or place in my code.So I cant find the source of the
problem with normal debugging.
Anybody any ideas on how to find the problem here??

TIA
patrick

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
        at javax.swing.LayoutComparator.compare(LayoutComparator.java:72)
        at java.util.Arrays.mergeSort(Arrays.java:1284)
        at java.util.Arrays.mergeSort(Arrays.java:1296)
        at java.util.Arrays.mergeSort(Arrays.java:1295)
        at java.util.Arrays.mergeSort(Arrays.java:1295)
        at java.util.Arrays.mergeSort(Arrays.java:1296)
        at java.util.Arrays.sort(Arrays.java:1223)
        at java.util.Collections.sort(Collections.java:159)
        at
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycle(SortingFocusTraversalPolicy.java:119)
        at
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocusTraversalPolicy.java:425)
        at
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusTraversalPolicy.java:148)
        at
javax.swing.SortingFocusTraversalPolicy.getDefaultComponent(SortingFocusTraversalPolicy.java:502)
        at
java.awt.FocusTraversalPolicy.getInitialComponent(FocusTraversalPolicy.java:149)
        at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:318)
        at java.awt.Component.dispatchEventImpl(Component.java:3841)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Window.dispatchEventImpl(Window.java:1774)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.SequencedEvent.dispatch(SequencedEvent.java:93)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Sean - 21 Aug 2005 10:19 GMT
> Ive got a swing application with quite a lot of code. With several JFrames
> being created at various stages.
[quoted text clipped - 44 lines]
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
>          at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Can we see the relevant code segments?
Andrew Thompson - 21 Aug 2005 10:43 GMT
>> Ive got a swing application with quite a lot of code.
..
>> Anybody any ideas on how to find the problem here??
..
>> Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
>>          at javax.swing.LayoutComparator.compare(LayoutComparator.java:72)
...
>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
>>          at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
>>
> Can we see the relevant code segments?

Since the OP has 'quite a lot of code' and every one of those
stack trace lines referred to a Sun class, it might be a bit
tricky for the OP to determine what he 'relevant code segments' are.

OTOH, preparing an SSCCE that displays (or resolves) the
problem might be worthwhile.
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"..When after all, it was you and me."
The Rolling Stones 'Sympathy For The Devil'

Roland - 21 Aug 2005 11:34 GMT
> Ive got a swing application with quite a lot of code. With several JFrames
> being created at various stages.
[quoted text clipped - 9 lines]
> Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
>          at javax.swing.LayoutComparator.compare(LayoutComparator.java:72)
[...]
Are you perhaps adding/removing/replacing components on a thread that's
*not* the EDT (Event dispatch thread)?
I've had a look at line 72 of LayoutComparator and it seems there's a
component in your GUI that doesn't have a Window object as one of its
parents. This can happen if you add/remove/replace a component outside
the EDT: a replaced component may get orphaned (has no Window parent)
while the EDT tries to dispatch a keyboard event (in your case) at the
'same' time.
Signature

Regards,

Roland de Ruiter
` ___      ___
`/__/ w_/ /__/
/  \ /_/ /  \



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.