AbstractTable model exception throws clause error?

I want to display a JDialog whenever the user tries to enter a string when the column class is Double. To do this, I am trying to throw an exception from the setValueAt() method in my class that extends AbstractTable model. However, my code results in an "Exception StatisticsException is not compatible with throws clause in AbstractTableModel.setValueAt()". Any idea how I can work around this? Is there a better way to display a JDialog in this case? Thanks in advance.

publicvoid setValueAt(Object text,int rowIndex,int columnIndex)throws StatisticsException{

if(variables[columnIndex].isDouble()){

try{

Double.parseDouble(text.toString());

Object[] temp = data.get(rowIndex);

temp[columnIndex] = text.toString();

data.remove(rowIndex);

data.add(rowIndex, temp);

}catch(NumberFormatException ex){

thrownew StatisticsException("Numeric value required.");

}

}else{

Object[] temp = data.get(rowIndex);

temp[columnIndex] = text.toString();

data.remove(rowIndex);

data.add(rowIndex, temp);

}

}

[1759 byte] By [Jstatsa] at [2007-11-26 19:06:10]
# 1

You don't override the setValueAt(...) method to do editing.

The default double editor will prevent you from entering an invalid value. You just need to tell the table the type in data in the column:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=627108

Or if you really want a message then you write a custom editor:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=645740

camickra at 2007-7-9 20:57:11 > top of Java-index,Desktop,Core GUI APIs...
# 2

Ah, yes of course. In the midst of trying to account for data entry errors, I forgot that. The following revised code works just fine. Thanks.

public void setValueAt(Object text, int rowIndex, int columnIndex){

Object[] temp = data.get(rowIndex);

temp[columnIndex] = text.toString();

data.remove(rowIndex);

data.add(rowIndex, temp);

}

Jstatsa at 2007-7-9 20:57:12 > top of Java-index,Desktop,Core GUI APIs...