This discussion is archived
1 2 Previous Next 26 Replies Latest reply: Oct 28, 2012 5:53 AM by ptoye RSS

Illegal Argument exception within Swing

ptoye Newbie
Currently Being Moderated
I've written a Swing-based program. When I start it there's an Illegal Argument exception with the message "Comparison method violates its general contract".

But the stack doesn't have any of my code in it - it's entirely on the AWT event queue (see copy of stack below). And there are no comparators in my program at all.

The program appears to run OK, but it's more than a bit disconcerting. Anyone here got any ideas what's going wrong inside Swing?

Thanks in advance,

Peter

Stack output is:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
     at java.util.TimSort.mergeLo(TimSort.java:747)
     at java.util.TimSort.mergeAt(TimSort.java:483)
     at java.util.TimSort.mergeCollapse(TimSort.java:410)
     at java.util.TimSort.sort(TimSort.java:214)
     at java.util.TimSort.sort(TimSort.java:173)
     at java.util.Arrays.sort(Arrays.java:659)
     at java.util.Collections.sort(Collections.java:217)
     at javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycle(SortingFocusTraversalPolicy.java:136)
     at javax.swing.SortingFocusTraversalPolicy.getFocusTraversalCycle(SortingFocusTraversalPolicy.java:110)
     at javax.swing.SortingFocusTraversalPolicy.getFirstComponent(SortingFocusTraversalPolicy.java:435)
     at javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(LayoutFocusTraversalPolicy.java:166)
     at javax.swing.SortingFocusTraversalPolicy.getDefaultComponent(SortingFocusTraversalPolicy.java:515)
     at java.awt.FocusTraversalPolicy.getInitialComponent(FocusTraversalPolicy.java:169)
     at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:380)
     at java.awt.Component.dispatchEventImpl(Component.java:4731)
     at java.awt.Container.dispatchEventImpl(Container.java:2287)
     at java.awt.Window.dispatchEventImpl(Window.java:2719)
     at java.awt.Component.dispatchEvent(Component.java:4687)
     at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
     at java.awt.EventQueue.access$200(EventQueue.java:103)
     at java.awt.EventQueue$3.run(EventQueue.java:682)
     at java.awt.EventQueue$3.run(EventQueue.java:680)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
     at java.awt.EventQueue$4.run(EventQueue.java:696)
     at java.awt.EventQueue$4.run(EventQueue.java:694)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
     at java.awt.SequencedEvent.dispatch(SequencedEvent.java:116)
     at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
     at java.awt.EventQueue.access$200(EventQueue.java:103)
     at java.awt.EventQueue$3.run(EventQueue.java:682)
     at java.awt.EventQueue$3.run(EventQueue.java:680)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
     at java.awt.EventQueue$4.run(EventQueue.java:696)
     at java.awt.EventQueue$4.run(EventQueue.java:694)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points