2 Replies Latest reply: Mar 26, 2010 5:02 AM by 843853 RSS

    to stop  the elaboration, waiting an user's answer

    843853
      Hi,

      I need (in a point of the program) that the data flow of the elaboration hangs for an answer coming from the user.

      In that point of the program a dialog is raised to pick up some data from the user, and the elaboration should be continue
      only when the user finished to fill the form in the dialog.

      I wrote this trivial solution that use a passive while cycle ...
              connectionRMIsucceded = requireNewDBconnectionInstance(objName);
              if (connectionRMIsucceded == false) {
                  boolean answerCame = false;
                  dialogToSetNetworking_onClientSide.setVisible(true);
                  long count = 0; // dummy cycle to wait the answer of the user
                  while (answerCame == false){// stop until  the answer come
                      answerCame = dialogToSetNetworking_onClientSide.getDone();
                      System.out.println("getDone () " + count++);
                  } // while 
                  dialogToSetNetworking_onClientSide.setVisible(false);
                  dialogToSetNetworking_onClientSide.dispose();
            } // if 
      I would, however, look for a better solution of this problem if it exists ...

      thank you regards

      tonyMrsangelo
        • 1. Re: to stop  the elaboration, waiting an user's answer
          jduprez
          I need (in a point of the program) that the data flow of the elaboration hangs for an answer coming from the user.
          In that point of the program a dialog is raised to pick up some data from the user, and the elaboration should be continue
          only when the user finished to fill the form in the dialog.
          This seems to call for a modal dialog (especially simple using one of the JOptionPane.showXxxDialog() methods). See the Swing tutorial chapter on [How to make dialogs|http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html] .
          Note that if you need other tasks to go on all the same (not waiting for user input), you can do that with threads (there are no restrictions about using threads underneath dialogs, except the usual Swing-specific threading rules, see the [dedicated chapter|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html] in the tutorial again).
          • 2. Re: to stop  the elaboration, waiting an user's answer
            843853
            hi jduprez .

            that is a good suggestion.

            I'll try it.

            thank you regards