Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDialog modal blocks not only user inputs, but also java code

843805Mar 19 2006 — edited Mar 19 2006
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2006
Added on Mar 19 2006
2 comments
150 views