• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding JTable data

 
tadi raja
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was created one JTable and i can add data to JTable as by extends the DefaultTableModel, if i pressed "clear" button the rows of DefaultTableModel can be cleared, and once again i add new data to JTable
Here is the implemented code of CustomTableModel that extends DefaultTableModel



i got the exception like this:

Exception: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementAt(Vector.java:434)
at com.hdsc.plus.app.vista.app.ivcheck.CustomTableModel.getValueAt(CustomTableModel.java:52)
at javax.swing.JTable.getValueAt(JTable.java:1771)
at com.perse.swing.standard.StandardTableUI.paint(StandardTableUI.java:49)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at com.perse.swing.standard.StandardScrollPane$MessageViewport.paint(StandardScrollPane.java:100)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4758)
at javax.swing.JComponent._paintImmediately(JComponent.java:4692)
at javax.swing.JComponent.paintImmediately(JComponent.java:4495)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

how to resolve this problem?

Thanks you in advance
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why this error occurs, but I have one major doubt about your code. If you are extending DefaultTableModel, then why are you recreating part of that functionality?

I'd use DefaultTableModels behaviour, and use it instead:

[ September 13, 2008: Message edited by: Rob Prime ]
 
tadi raja
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob Prime

I found the solution, your code worked perfectly without any exception.

Thanks alot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic