Salve a tutti, ho creato un model da associare ad una JTable, vi posto il codice:
codice:
public class DataModel extends AbstractTableModel implements ActionListener {

    private String[] headers = {"", Main.ls.getValue("rilevaprod_commessa"), Main.ls.getValue("rilevaprod_articolo"), Main.ls.getValue("rilevaprod_sezione"), Main.ls.getValue("rilevaprod_operazione"), Main.ls.getValue("rilevaprod_taglia"), Main.ls.getValue("rilevaprod_capi")};
    private Class[] columnTypes = {JButton.class, String.class, String.class, String.class, String.class, String.class, String.class};
    private Vector<Vector<Object>> data = new Vector<Vector<Object>>();
    ImageIcon cancicon = new ImageIcon(getClass().getResource("/programmatunisia/GraphicalUserInterface/images/del16x16.png"));

    public void appendRow(String a, String b, String c, String d, String e, String f) {
        Vector<Object> row = new Vector<Object>();
        JButton cancel = new JButton();
        cancel.setIcon(cancicon);
        cancel.setContentAreaFilled(false); // no riempimento
        cancel.setBorder(null); // no bordo
        cancel.setFocusPainted(false); // no focus
        cancel.setFocusable(false);
        cancel.addActionListener(this);
        cancel.repaint();
        row.add(cancel);
        row.add(a);
        row.add(b);
        row.add(c);
        row.add(d);
        row.add(e);
        row.add(f);
        data.add(row);
        fireTableStructureChanged();
        RilevaProduzione.labLav.setText(String.valueOf(getRowCount()));
        RilevaProduzione.labNum.setText(String.valueOf(getPezziCount(getRowCount())));
    }

    public int getRowCount() {
        return data.size();
    }

    public int getColumnCount() {
        return headers.length;
    }

    public void setValueAt(Object v, int row, int col) {
        data.get(row).set(col, v);
    }

    public Class getColumnClass(int col) {
        return columnTypes[col];
    }

    public String getColumnName(int col) {
        return headers[col];
    }

    public boolean isCellEditable(int row, int col) {
        return col==0;
    }

    public Object getValueAt(int row, int col) {
        return data.get(row).get(col);
    }

    public int getPezziCount(int numrow) {
        int total = 0;
        for (int i = 0; i < numrow; i++) {
            total = total + Integer.parseInt(getValueAt(i, 6).toString());
        }
        return total;
    }

    public void actionPerformed(ActionEvent e) {
        int row = getRowForButton(e.getSource());
        if (row == -1) {
            throw new RuntimeException("DataModel, no row for button!!!???");
        }
        data.remove(row);
        fireTableStructureChanged();
        RilevaProduzione.labLav.setText(String.valueOf(getRowCount()));
        RilevaProduzione.labNum.setText(String.valueOf(getPezziCount(getRowCount())));
    }

    private int getRowForButton(Object o) {
        for (int k = 0; k < data.size(); k++) {
            if (data.get(k).get(0) == o) {
                return k;
            }
        }
        return -1;
    }
};
e le relative classi per l'editing e il rendering:

codice:
public class ButtonEditor implements TableCellEditor {
	public Component getTableCellEditorComponent(JTable t, Object value,
		boolean isSelected, int row, int column)
	{
		return (JButton)value;
	}

	public Object getCellEditorValue() { return null; }
	public void cancelCellEditing() {}
	public boolean stopCellEditing() { return true;	}
	public boolean shouldSelectCell(EventObject o) { return true; }
	public boolean isCellEditable(EventObject o) { return true;	}
	public void addCellEditorListener(CellEditorListener l) {}
	public void removeCellEditorListener(CellEditorListener l) {}
};
codice:
public class ButtonRenderer implements TableCellRenderer {
	public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, boolean hasFocus, int row, int column)
	{
		return (JButton)value;
	}
}
fin qui tutto ok, la tabella viene creata correttemente e funge tutto alla perfezione.
codice:
DataModel model = new DataModel();
JTable tableProd = new JTable(model);

tableProd.setRowHeight(24);
tableProd.setDefaultRenderer(JButton.class, new ButtonRenderer());
tableProd.setDefaultEditor(JButton.class, new ButtonEditor());
Ora quello che vorrei fare è di settare alcuni parametri sulla tabella, e faccio nel seguente modo, ma non ottengo nessun effetto.
codice:
        tableProd.getColumnModel().getColumn(0).setResizable(false);
        tableProd.getColumnModel().getColumn(1).setResizable(false);
        tableProd.getColumnModel().getColumn(2).setResizable(false);
        tableProd.getColumnModel().getColumn(3).setResizable(false);
        tableProd.getColumnModel().getColumn(4).setResizable(false);
        tableProd.getColumnModel().getColumn(5).setResizable(false);
        tableProd.getColumnModel().getColumn(6).setResizable(false);
        tableProd.setFocusable(false);
        tableProd.getColumnModel().getColumn(0).setMinWidth(50);
        tableProd.getColumnModel().getColumn(0).setMaxWidth(50);
        tableProd.getColumnModel().getColumn(1).setMinWidth(80);
        tableProd.getColumnModel().getColumn(1).setMaxWidth(80);
        tableProd.getColumnModel().getColumn(1).setCellRenderer(new CenterCellRenderer());
        tableProd.getColumnModel().getColumn(2).setMinWidth(40);
        tableProd.getColumnModel().getColumn(2).setMaxWidth(40);
        tableProd.getColumnModel().getColumn(2).setCellRenderer(new CenterCellRenderer());
        tableProd.getColumnModel().getColumn(3).setMinWidth(90);
        tableProd.getColumnModel().getColumn(3).setMaxWidth(90);
        tableProd.getColumnModel().getColumn(3).setCellRenderer(new CenterCellRenderer());
        tableProd.getColumnModel().getColumn(4).setMinWidth(90);
        tableProd.getColumnModel().getColumn(4).setMaxWidth(90);
        tableProd.getColumnModel().getColumn(5).setMinWidth(30);
        tableProd.getColumnModel().getColumn(5).setMaxWidth(30);
        tableProd.getColumnModel().getColumn(6).setMinWidth(30);
        tableProd.getColumnModel().getColumn(6).setMaxWidth(30);
Qualcuno ha qualche idea su come settare la larghezza delle colonne..ecc...ecc...

n.b. Notavo invece che la riga di codice tableProd.setRowHeight(24); funziona perfettamente!!