JDialog modal blocks not only user inputs, but also java code
843805Mar 19 2006 — edited Mar 19 2006I have made a JProgressDialog derived from a JDialog class. This dialog does not contains any button: it should close automatically when its work ends. It contains a progressbar object, whose value is set in a loop. The whole thing is executed in a separed thread, a SwingWorker (3):
Here is the code (simplified):
final SwingWorker worker = new SwingWorker() {
public Object construct() {
//some code
JProgressDialog pDial = new JProgressDialog(mainJFrame.this);
pDial.setModal(true);
pDial.setVisible(true);
// now that the dialog is shown, the code below will never execute . Why?
for( int i = 0; i < fileList.length; i++ ) {
pDial.setValue(i + 1); //sets the progressbar value
// some code
}
pDial.setVisible(false);
return pDial;
} //construct
}; //SwingWorker
worker.start();
So my question is: i know that modal dialog block user inputs, but why it does block code excecution too?
Regars,
Ga�tan.