Can't start Thread from modal JDialog.

Hi,

this is a part of my code. I can't start the scanThread from the object WaitingDl. But if i close the modal JDialog (WaitingDl) the scanThread starts, please help:

Thread scanThread = new Thread() {

public void run() {

// do something ....

// .....

}

};

WaitingDl waitFrame = new WaitingDl("Waiting process", parent, scanThread, "Please wait ...");

class WaitingDl extends JDialog {

public WaitingDl(String title, JFrame parent, Thread thread, String waitingText) {

// a modal Dialog

super(parent,true);

// This command doesn't work!

scanThread.start();

}

}

Thanks!

[702 byte] By [turjalei] at [2007-9-26 3:14:25]
# 1

Hi,

As suggestion :

I think your JDialog is modal and visible by default, so

when you invoke the contructor :

WaitingDL d=new ......

you enter to "modal state" so the Event thread is blocked and this append when you invoke super at

contructor level.

If you set your dialog not visible you can do :

WaitingDL d=new .........

// at this moment the contructor is invoked but the event thread is not blocked so your thread is started

d.setVisible(true);

// at this point the dialog is visible you enter at a modal state but your thread is running

Hope this help

Bye

yomismo at 2007-6-29 11:24:38 > top of Java-index,Archived Forums,Swing...