simple yet stubborn repaint problem

Class Viewerextends JPanelimplements ActionListener{

.

.

publicvoid actionPerformed(ActionEvent e){

Object event = e.getSource();

if(event == button1){

clearTable();

repaint();

}

if(event == button2){

refreshTable();

repaint();

}

if(event == button3){

clearTable();

repaint();

refreshTable();

repaint();

}

.

.

}

Now for the doubt,

1) click on button1 and then button2 seems to work fine. It first resets the table with "nil" values on button1 and after pressing button2, it fills in the data extracted by refreshTable() function.

2) button3 by logic needs to do the work of button1 followed by button2. But click on button3 does not reset the table with "nil" values, but directly seems to do the second half which button2 does, that is load the data.

This bothers me because, refreshTable() causes multiple threads to be spawned and each thread retrieves data in different paces. In the meanwhile, the cells that have old data should show "nil" until the new data is being retrieved by a thread. But instead, the old data doesnt seem to be replaced with a "nil".

clearTable(): This function creates a vector of vectors each having a value "nil". This is set to be the new data model for the table and then repaint() is called on the application as whole by calling "repaint()"

refreshTable(): This function creates multiple threads to fetch results to fill in to the table. Each of these threads set the appropriate row vector in the data model and then call repaint on this singleton application in a static way by Application.Viewer.repaint();

What could be the fault?

[2228 byte] By [toxiga] at [2007-11-27 3:09:25]
# 1

No idea what you are asking, but you don't need to use repaint(). Whenever you use the DefaultTableModel and use methods to clear the model or remove rows from the model the table will repaint itself automatically.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-12 3:58:19 > top of Java-index,Desktop,Core GUI APIs...