selecting JTable row after model changed

Hello

I have a table, and I need to change data in the underlying model and then select a row...

so i tryed something like this:

table.getModel().addTableModelListener(new TableModelListener(){

publicvoid tableChanged(TableModelEvent tableModelEvent){

...

table.addRowSelectionInterval(i, i);

...

}

});

..but that doesn't work, probably because when TableModelEventFires, the table is not yet rendered...

so, the question is, is there an event that fires right after the whole table has been drawn, and if not, how do I write one?

[809 byte] By [nite23a] at [2007-11-26 18:34:18]
# 1
> ..but that doesn't work, probably because when> TableModelEventFires, the table is not yet> rendered...What do you mean by doesn't work? (The rows don't get selected?) Can you provide a SSCCE program?
zadoka at 2007-7-9 6:08:25 > top of Java-index,Desktop,Core GUI APIs...
# 2

Try placing the selection code inside SwingUtilities.invokeLate.

SwingUtilities.invokeLater(new Runnable() {

public void run() {

table.addRowSelectionInterval(i, i);

}

});

Rodney_McKaya at 2007-7-9 6:08:25 > top of Java-index,Desktop,Core GUI APIs...
# 3
that works, thanks!
nite23a at 2007-7-9 6:08:25 > top of Java-index,Desktop,Core GUI APIs...