• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable throwing exception when loaded

 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Rgs,
Fl�vio.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the code from your TableCellRenderer, since it looks like that is what is causing the problem...
 
Rob Elliott
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan!

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??

Thanks,
Rob.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!