I am using JTable to display data, but I need use JTable to edit data too.
JTable is not allowing editing cells in MySaifu, I am making the cells editable overriding the method of the class javax.swing.table.DefaultTableModel.
The following code reproduce the bug.
public class TableTest extends JFrame {
public TableTest(String title) {
super(title);
setSize(150, 150);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
dispose();
System.exit(0);
}
});
init();
pack();
setVisible(true);
}
private void init() {
JTable jt = new JTable(new TestTableModel());
JScrollPane pane = new JScrollPane(jt);
getContentPane().add(pane);
}
public static void main(String[] argv) {
new TableTest("JTable Example");
}
}
public class TestTableModel extends DefaultTableModel {
private static Object data[][] = { { "John", "Sutherland", "Student" },
{ "George", "Davies", "Student" },
{ "Melissa", "Anderson", "Associate" },
{ "Stergios", "Maglaras", "Developer" }, };
private static Object fields[] = { "Name", "Surname", "Status" };
public TestTableModel() {
super(data, fields);
}
public boolean isCellEditable(int row, int column) {
return true;
}
}
Be able of edit JTable cells is very important to improve usability of the user inteface in my system.
I am using JTable to display data, but I need use JTable to edit data too.
JTable is not allowing editing cells in MySaifu, I am making the cells editable overriding the method of the class javax.swing.table.DefaultTableModel.
The following code reproduce the bug.
Be able of edit JTable cells is very important to improve usability of the user inteface in my system.