import javax.swing.*;
import javax.swing.table.AbstractTableModel;

public class MutableTableModel extends AbstractTableModel {

  public MutableTableModel(double[] prices) {
    this.prices=prices;
  }

  public int getColumnCount() {
    return 2;
  }

  public int getRowCount() {
    return prices.length;
  }
  
  public String getColumnName(int column) {
    return (column==0)?"prix HT":"prix TTC";
  }
  
  public Class getColumnClass(int columnIndex) {
    return Double.class;
  }

  public Object getValueAt(int row, int column) {
    double price=prices[row];
    return (column==0)?
      new Double(price):
      new Double(price*1.206);
  }
  
  public boolean isCellEditable(int row, int column) {
    return column==0;
  }
  
  public void setValueAt(Object value, int row, int column) {
    prices[row]=((Double)value).doubleValue();
    fireTableRowsUpdated(row, row);
  }
  
  private final double[] prices;
  
  public static void main(String[] args) {
    double prices[] =new double[] {
      2.50, 123.0, 456.75, 134.95, 123.45, 89.99, 124.99
    };
    MutableTableModel model=new MutableTableModel(prices);
    
    JTable table=new JTable(model);
    
    JFrame frame=new JFrame("MutableTableModel");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new JScrollPane(table));
    frame.setSize(400,300);
    frame.show();
  }
}