I have a serious problem, removing rows from my JTable, my code is the same as what I saw when I tried to learn AbstractTableModel:
import javax.swing.table.AbstractTableModel;
public class MyTableModel extends AbstractTableModel {
boolean DEBUG = true;
input_Data input = new input_Data();
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Kathy", "Smith",
"Snowboarding", new Integer(5), new Boolean(false)},
{"John", "Doe",
"Rowing", new Integer(3), new Boolean(true)},
{"Sue", "Black",
"Knitting", new Integer(2), new Boolean(false)},
{"Jane", "White",
"Speed reading", new Integer(20), new Boolean(true)},
{"Joe", "Brown",
"Pool", new Integer(10), new Boolean(false)};
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return data.length;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int col) {
if (col < 2) {
return false;
} else {
return true;
}
}
public void removeRow(Row)
{
fireTableRowsDeleted(Row,Row);
}
}
But the problem is that nothing happens when I call removeRow!! I think that maybe I should edit data too, but how? I am new to java and I really got stock into this problem...