
Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
On Mon, 31 Dec 2007 04:42:03 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :
>I have noticed that when my JTable is scrolling, it sometimes displays
>the heading line temporarily before replacing it with the proper data
>line. Is this a bug in Swing, or am I doing something wrong?
I found a pragmatic solution. After I make my calls that will trigger
gui changes, I use Thread.yield(); in my computational thread to give
the Swing thread a crack at processing the GUI events.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Roedy Green - 31 Dec 2007 12:42 GMT
On Mon, 31 Dec 2007 04:48:48 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :
>I found a pragmatic solution. After I make my calls that will trigger
>gui changes, I use Thread.yield(); in my computational thread to give
>the Swing thread a crack at processing the GUI events.
I still get sporadic anomalies.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Alexander.V.Kasatkin@gmail.com - 31 Dec 2007 18:01 GMT
It's normal situation if a table model is updated by a non-Swing
thread.
IMHO, If you've extends an AbstractTableModel class, you can override
the fireTableChanged method:
<pre>
public class Model extends DefaultTableModel {
private static final long serialVersionUID =
-5792073620222974655L;
@Override
public void fireTableChanged(final TableModelEvent e) {
if (SwingUtilities.isEventDispatchThread()) {
super.fireTableChanged(e);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
fireTableChanged(e);
}
});
}
}
}
</pre>