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