PDA

Click to See Complete Forum and Search --> : An Exception that freaked me out


ComputerJy
Apr 8th, 2009, 04:36 AM
During the execution of one of my programs I got multiple java exceptions (From java's code itself) when getting a value from a table cell.

So I wrapped the DefaultTableModel into another class
import java.util.EmptyStackException;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;

public class TempTableModel extends DefaultTableModel
{
private static final long serialVersionUID = -2618201765315591851L;

public TempTableModel(Object[][] data, Object[] columnNames)
{
super(data, columnNames);
}

public TempTableModel(Vector data, Vector columnNames)
{
super(data, columnNames);
}

public TempTableModel(Object[] columnNames, int rowCount)
{
super(columnNames, rowCount);
}

public TempTableModel(Vector columnNames, int rowCount)
{
super(columnNames, rowCount);
}

public TempTableModel(int rowCount, int columnCount)
{
super(rowCount, columnCount);
}

public TempTableModel()
{
}

@Override
public Object getValueAt(int row, int column)
{
try
{
return super.getValueAt(row, column);
}
catch (java.lang.ArrayIndexOutOfBoundsException ex)
{
throw ex;
}
}
}

I use Netbeans by the way, so I added a break point to the {throw ex} line and.. well, it stopped. Unfortunately I added a watch to the value {super.getValueAt(row, column)}.

Thought I'd get an Exception but instead I got a value, and a correct value.
I looked at the Thread pool and there were 3 threads running, only one of them (the current) had anything to do with the table's data.

In the name of all cakes, what's going on

ComputerJy
Apr 8th, 2009, 04:43 AM
Sorry, I forgot to mention I'm using Ubuntu 9.04 beta, with java 1.5.0_18
And when I tried my code on Windows Vista, there were no exceptions

The Exception's stack trace:
java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(Vector.java:432)
at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:621)
at javax.swing.JTable.getValueAt(JTable.java:1903)
at javax.swing.JTable.prepareRenderer(JTable.java:3911)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1897)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:743)
at javax.swing.JComponent.paint(JComponent.java:1006)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4972)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
at javax.swing.JComponent._paintImmediately(JComponent.java:4868)
at javax.swing.JComponent.paintImmediately(JComponent.java:4675)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
at java.awt.Dialog$1.run(Dialog.java:535)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)