Cannot find problem with java.lang.ArrayIndexOutOfBoundsException

I have a problem with my application that returns this error several times in the console, but I can not find the source (all Unknown source). It seems that the application is working correctly after this error, but I want to understand what appening is ... How can I do this?

Thank you and sorry for my english!

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.getPreferredSize(Unknown Source) at javax.swing.JComponent.getPreferredSize(Unknown Source) at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source) at java.awt.Container.layout(Unknown Source) at java.awt.Container.doLayout(Unknown Source) at java.awt.Container.validateTree(Unknown Source) at java.awt.Container.validate(Unknown Source) at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 
+4
source share
2 answers

If you look at the source of BasicListUI.updateLayoutState() , this can only happen when the displayed list changes size during the execution of the method.

The most likely reason is that you are modifying the model from outside the event dispatch stream . This is a serious problem, as it can lead to all kinds of strange behavior and even to corrupt data.

To fix the problem, use SwingUtilities.invokeLater() when you need to manipulate the model outside of EDT.

+11
source

This type of error is sometimes caused by updating GUI components off EDT when it needs to be done on EDT.

If fixing any code that violates this principle does not solve the problem, I suggest you try preparing SSCCE and sending it to the stream.

+1
source

Source: https://habr.com/ru/post/1342668/


All Articles