Salve. Qualcuno sa dirmi perchè non riesco a visualizzare i nomi delle colonne di questa JTable? E inoltre, come faccio a rendere le celle non modificabili oppure modificabili? E come faccio ad ottenere un valore di una cella appena modificata da un utente?
codice:
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
public class TestTable extends JFrame
{
public TestTable()
{
super ("Test Table");
setSize (400, 300);
setLocationRelativeTo (null);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JTable table = new JTable
(
new AbstractTableModel()
{
public int getColumnCount() { return 10; }
public int getRowCount() { return 10; }
public Object getValueAt (int row, int col) { return new Integer ((row + 1) * (col + 1)); }
public Class getColumnClass (int column) { return Object.class; }
public String getColumnName (int column) { return "Nome"; }
}
);
add (table);
setVisible (true);
}
public static void main (String[] args)
{
new TestTable();
}
}