I have an application that I want to create my own dialog screens. For example, the user cliks on one frame, and I want to open a window for the user to enter data, after the user finishes, he presses OK and then the main app continues.

On the class that I open the dialog, I open it with:

NewOkCancelDialog.abrePopup();
     System.out.println("Program should wait for the dialog to close");

And the 'NewOkCancelDialog' class is defined like:

public class NewOkCancelDialog extends javax.swing.JDialog {

The constructor is like:

public NewOkCancelDialog(java.awt.Frame parent, boolean modal) {
 super(parent, true);
 initComponents();
 this.setLocation(400,400);
    }

This methods are when the user activates the button and the popup closes..

private void cierraPopupOk(){
 resultados.setciudad1(this.fld_ciudad1.getText());
 if (resultados.getciudad1length() < 3) {
     System.out.println("Error en la entrada!");
 } else {
     doClose(RET_OK);
 }
    }
   
    
    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
 cierraPopupOk();
    }                                        

 
  private void doClose(int retStatus) {
 returnStatus = retStatus;
 this.estaAbierto = false;
 setVisible(false);
 dispose();
    }

I would like to have the application in the first lines, after calling

NewOkCancelDialog.abrePopup();

to wait until the method doClose() in NewOkCancelDialog class is finnished. But right now, after the ...abrePopup() is called, it continues.

What am I doing wrong? or what am I not doing?

To follow up all the left processing after the ok button is clicked you can do like this

1) Define a new function in which you put all the code you want to process after the dialog box is clicked ok.

2) Now in your cierraPopupOk() call the function after your doClose(RET_OK) processing is finished.
Ex

.
.
.
.
.
private void cierraPopupOk(){
 resultados.setciudad1(this.fld_ciudad1.getText());
 if (resultados.getciudad1length() < 3) {
     System.out.println("Error en la entrada!");
 } else {
     doClose(RET_OK);
     newFunction();
 }
    }
..
.
.
public void newFunction()
{
// Here you put the code  whatever  you want to do after the ok button is clicked
}
This article has been dead for over six months. Start a new discussion instead.