Hi, Does anyone know why my JTable is throwing this exception?
java.lang.ArrayIndexOutOfBoundsException: 4 >= 4 at java.util.Vector.elementAt(Unknown Source) at javax.swing.table.DefaultTableColumnModel.getColumn(Unknown Source) at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source) at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source) at javax.swing.plaf.ComponentUI.update(Unknown Source) at javax.swing.JComponent.paintComponent(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source) at javax.swing.JComponent.paintDoubleBuffered(Unknown Source) at javax.swing.JComponent._paintImmediately(Unknown Source) at javax.swing.JComponent.paintImmediately(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)
Sometimes it is throwed sometimes not, and I don't know what cause this. Regards, Fl�vio.
It looks like you have made a custom table model and there is an off-by-one error in one of the methods... i.e. you have a 4 column table, but that means the columns are numbered 0-3, and somewhere something is trying to access column 4.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Hi Nathan, In fact it started to happen when I built a customized TableCellRenderer. It's strange, because the exception sometimes is throwed and sometimes is not, even without changing anything. And I have seven columns, but the exception says the index must be less than 4.
Did you discover what your problem was on this one?
I'm receiving the same exception, stack trace however in my case I'm reordering table columns. After I receive it, I'm able to continue reordering columns without any problems. It only happens on my first re-order attempt??
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop