Java: Converting data types
<p>I'm working with a <code>JTable</code>, whose cells data are contained in <code>Object</code>. One column shows a <code>float</code> number. I want to GET the value into a<code>float</code>, limit decimal places to 3, and then I want to reload the correct data in the cell, so I want to SET the value into the cell again. The problem appears in the last conversion:</p>

<pre><code> private class CambioTablaMeasurementListener implements TableModelListener{

    public void tableChanged(TableModelEvent e){
        try{
            if(sendDataToDisp){
                TableModel model = (TableModel)e.getSource();
                float value = Float.parseFloat((String)model.getValueAt(e.getLastRow(), 1));
               // Now i want to limit to only 3 decimal places, so:

                double aux = Math.round(value*1000.0)/1000.0;
                value = (float) aux;
                Float F = new Float(value);

                // Now i want to load data back to the cell, so if you enter 0.55555, the cell shows 0.555. This Line gives me an exception (java.lang.Float cannot be cast to java.lang.String):
                model.setValueAt(F, e.getLastRow(), 1);

                // Here I'm getting another column, no problem here:
                String nombreAtributo = (String)model.getValueAt(e.getLastRow(), 0);
                nodoAModificar.setCommonUserParameter(nombreAtributo, value);

            }
           ...}
</code></pre>
