I have the below spinet of code which basically consists of a panel with a progress bar. The progress bar indicates the completion rate for the numerical computations executed in RunComputations(). It takes several seconds for the computations to be completed. RunComputations is called after an instance has been created.
I would like this this panel (basin) to be modal but I can't. JVM stops at dialog.setVisible(true) and waits for an action on behalf of the user. Is there anyway to have a modal panel in these circumstances?
*********************
//this code invokes Basin Panel
Basin basin = new Basin(); //JVM does not proceed after this point.
basin.RunComputations();
//Basin panel is called by the above code
public class Basin extends javax.swing.JPanel {
private JDialog dialog;
Basin(){
dialog = new JDialog(fr,"Running Model...",true);
dialog.add(this);
dialog.setSize(430,130);
dialog.setModalityType(ModalityType.APPLICATION_MO DAL); //If MODELESS is used here my program works as expected
dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ ON_CLOSE);
dialog.setVisible(true); //JVM stops here.
}
void RunComputations(){
//Computations are run and progress bar is updated
}