class DoubleRenderer extends JLabel implements CellComponent
{
DecimalFormat df = new java.text.DecimalFormat("0.000");
public void setValue(Object value)
{
setText(df.format((Double)value));
}
public JComponent getComponent()
{
return this;
}
//for rendererer the below methods will not be called
public Object getValue()
{
returen null;
}
public void addActionListener(ActionListener listener){}
}
class DoubleEditor extends JTextField implements CellComponent
{
DecimalFormat df = new java.text.DecimalFormat("0.000");
public void setValue(Object value)
{
setText(df.format((Double)value));
}
public JComponent getComponent()
{
return this;
}
public Object getValue()
{
return new Double(df.parse(getText()).doubleValue());
}
public void addActionListener(ActionListener listener){}
}
//if readonly table, you just need renderer
yourColumn.setUserCellRenderer(new DoubleRenderer())
yourColumn.setUserCellEditor(new DoubleEditor()),