I have a question here for you guys... This is a multithread app in
Swing.
I have a JTable within a JScrollPane. I have several text boxes so that
I can type in some product data (I have product category associates with
the input data). Each person can input data for any product category,
but is only responsible for One category. There are two things going on
here: a user can manually update the JTable by clicking the 'Add'
button, and then fire up an auto-refresh thread to exam the data in
database and update JTable every 10 seconds. I would imagine that you
need to stop the existing auto-refresh, if there is any, once you click
the 'Add', and then start a new auto-refresh.
The problem that I have is: I can manually update the table without the
auto-refresh involved. The auto-refresh doesn't seem to work. It is not
the JDBC portion, because I could see in debug more data is coming back.
It has to be something related to the Swing's single thread rule or
timer related. All I got was the Jtable with no data showing in it. (I
tried to create my own thread or use a timer, tried repaint(),
fireXXX-events, and all other methods that I could find from internet).
Please shed some lights on this one, what is the procedure that I need
to go thru.
---yxie
Any updates to the ui should be happening in this thrad. So if you were
going to change the model from Thread A, you would do:
Runnable r = new Runnable() {
public void run() {
myTable.setModel(newModel);
// or myTable.fireTableDataChanged();
}
};
SwingUtilties.invokeLater(r);
"Yang Xie" <yx...@ziplink.net> wrote in message
news:3E858D44...@ziplink.net...