Unknown error in java swing application -


hi use second thread update defaulttablemodel of jtable each 2 seconds , aparently randomly, throws me following error.

     exception in thread "awt-eventqueue-0" java.lang.arrayindexoutofboundsexception: 2 >= 2     @ java.util.vector.elementat(vector.java:470)     @ javax.swing.table.defaulttablemodel.getvalueat(defaulttablemodel.java:649)     @ javax.swing.jtable.getvalueat(jtable.java:2716)     @ javax.swing.jtable.preparerenderer(jtable.java:5714)     @ javax.swing.plaf.basic.basictableui.paintcell(basictableui.java:2108)     @ javax.swing.plaf.basic.basictableui.paintcells(basictableui.java:2010)     @ javax.swing.plaf.basic.basictableui.paint(basictableui.java:1806)     @ javax.swing.plaf.componentui.update(componentui.java:161)     @ javax.swing.jcomponent.paintcomponent(jcomponent.java:769)     @ javax.swing.jcomponent.paint(jcomponent.java:1045)     @ javax.swing.jcomponent.paintchildren(jcomponent.java:878)     @ javax.swing.jcomponent.paint(jcomponent.java:1054)     @ javax.swing.jviewport.paint(jviewport.java:731)     @ javax.swing.jcomponent.paintchildren(jcomponent.java:878)     @ javax.swing.jcomponent.paint(jcomponent.java:1054)     @ javax.swing.jcomponent.painttooffscreen(jcomponent.java:5212)     @ javax.swing.bufferstrategypaintmanager.paint(bufferstrategypaintmanager.java:295)     @ javax.swing.repaintmanager.paint(repaintmanager.java:1236)     @ javax.swing.jcomponent._paintimmediately(jcomponent.java:5160)     @ javax.swing.jcomponent.paintimmediately(jcomponent.java:4971)     @ javax.swing.repaintmanager$3.run(repaintmanager.java:796)     @ javax.swing.repaintmanager$3.run(repaintmanager.java:784)     @ java.security.accesscontroller.doprivileged(native method)     @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:76)     @ javax.swing.repaintmanager.paintdirtyregions(repaintmanager.java:784)     @ javax.swing.repaintmanager.paintdirtyregions(repaintmanager.java:757)     @ javax.swing.repaintmanager.prepaintdirtyregions(repaintmanager.java:706)     @ javax.swing.repaintmanager.access$1000(repaintmanager.java:62)     @ javax.swing.repaintmanager$processingrunnable.run(repaintmanager.java:1651)     @ java.awt.event.invocationevent.dispatch(invocationevent.java:251)     @ java.awt.eventqueue.dispatcheventimpl(eventqueue.java:727)     @ java.awt.eventqueue.access$200(eventqueue.java:103)     @ java.awt.eventqueue$3.run(eventqueue.java:688)     @ java.awt.eventqueue$3.run(eventqueue.java:686)     @ java.security.accesscontroller.doprivileged(native method)     @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:76)     @ java.awt.eventqueue.dispatchevent(eventqueue.java:697)     @ java.awt.eventdispatchthread.pumponeeventforfilters(eventdispatchthread.java:242)     @ java.awt.eventdispatchthread.pumpeventsforfilter(eventdispatchthread.java:161)     @ java.awt.eventdispatchthread.pumpeventsforhierarchy(eventdispatchthread.java:150)     @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:146)     @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:138)     @ java.awt.eventdispatchthread.run(eventdispatchthread.java:91) 

the program keeps working great, don't know fault in code, because none of classes appear in stack trace.

welcome wonderful world of event dispatch thread violation (and race conditions).

basically, should never update (directly or indirectly) ui component thread other edt.

basically, when update tablemodel, firing event, been caught table, trying update itself, models state in flux , not make sense table...

instead, trying using swingworker update model, using publish , process methods keep updates synchronised edt

check out concurrency in swing more details , examples.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -