Re: how to make the JTable.editCellAt(row,col) work
I'd got it,
the editCellAt(row,col) should invoked after the frame painted,
then it will work(though I'd not know why),
the code is as follows:
frame.setVisible(true);
table.editCellAt(row,col);
the main problem is that I need editCellAt custom cell while the
editing stopped,
the default sequence whould be [ (row,col)]
,(0,0),(0,1),....(1,0),(1,1)...
and I need the sequence likes (0,0),(1,0),(0,1),(1,1)....
I tried this at the tableModelListener ,the code is as follows:
class ModelListener implements TableModelListener {
public void tableChanged(TableModelEvent e) {
tableModel.removeTableModelListener(this);
int editingRow = table.getEditingRow();
int editingColumn = table.getEditingColumn();
if(editingRow == 0 && editingColumn == 0){
table.requestFocusInWindow();
table.editCellAt(1, 1);
tableModel.addTableModelListener(this);
}
}
}
and this can't work,I think the problem may be the table will be
repainted after the tableChanged, so the editCell will be removed,
all right ,I know the JTable's actionMap can do this for the key
event,but without the mouse pressed,
so who can give me some tips?
best regards,
Richard