The getValueAt() method of the TableModel interface returns a descendant of Object. Your error message indicates it is a String. So it seems that you should convert the Object reference returned to a String reference with a cast. Then convert that String to a double with Double.parseDouble(). parseDouble will throw a NumberFormatException if the string is not a valid double:
try {
numberRow = TOrders.getSelectedRow();
String temp = (String) TOrders.getModel().getValueAt(numberRow, 3);
subCost = Double.parseDouble(temp);
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(null, "Item in table was not a valid double - "
+ e.getMessage() );
}
If you want to deal with currency data, you may want to put it in a BigDecimal. Constructing a BigDecimal with a String that does not contain a valid decimal number throws a NumberFormatException.
try {
numberRow = TOrders.getSelectedRow();
String temp = (String) TOrders.getModel().getValueAt(numberRow, 3);
subCost = new BigDecimal(temp);
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(null,
"Item in table was not a valid decimal number");
}