aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes regarding JTable data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "regarding JTable data" Watch "regarding JTable data" New topic
Author

regarding JTable data

tadi raja
Ranch Hand

Joined: Jul 07, 2008
Posts: 109
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

Joined: Oct 27, 2005
Posts: 19693
    
  20

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 ]

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
tadi raja
Ranch Hand

Joined: Jul 07, 2008
Posts: 109
Hi Rob Prime

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

Thanks alot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding JTable data