java eqivalent for Application.DoEvents()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NagarajanS
    New Member
    • Dec 2006
    • 39

    java eqivalent for Application.DoEvents()

    Hi,
    can any one tell me the eqivalent for Application.DoE vents() in java.I am swing application so i need to do this to elimate the hangling of my application.
    Regards,
    nags.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by NagarajanS
    Hi,
    can any one tell me the eqivalent for Application.DoE vents() in java.I am swing application so i need to do this to elimate the hangling of my application.
    Regards,
    nags.
    What does Application.DoE vents() do?

    Comment

    • NagarajanS
      New Member
      • Dec 2006
      • 39

      #3
      Application.DoE vents() is the method wich is used to do any user interaction in the parent form.for example
      while(true)
      {
      //some code
      }
      if you do any updation inside this while loop then the application will hanges.so if we want to elimate that condition just put "Application.Do Events()" inside the loop.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by NagarajanS
        Application.DoE vents() is the method wich is used to do any user interaction in the parent form.for example
        while(true)
        {
        //some code
        }
        if you do any updation inside this while loop then the application will hanges.so if we want to elimate that condition just put "Application.Do Events()" inside the loop.
        Why don't you post the Java code that you have and explain the problem you are getting in the code.

        Comment

        • questionit
          Contributor
          • Feb 2007
          • 553

          #5
          NagarajanS should have also mentioned that DoEvents is a VB function.

          DoEvents function returns control to the operating system while a loop is still executing.

          NagarajanS wants to know similar functions in Java.

          Qi

          Originally posted by r035198x
          Why don't you post the Java code that you have and explain the problem you are getting in the code.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by questionit
            NagarajanS should have also mentioned that DoEvents is a VB function.

            DoEvents function returns control to the operating system while a loop is still executing.

            NagarajanS wants to know similar functions in Java.

            Qi
            I'd still like to see the Java code he has for this and where it's giving problems. In Java the thread responsible for painting is different from the thread running the whole application so I (for one) am not yet fully visualizing his problem in the Java context. Thanks for the explanation of what DoEvents does.

            Comment

            • NagarajanS
              New Member
              • Dec 2006
              • 39

              #7
              here is the code,
              [CODE=java] private void PlayLinkActionP erformed(java.a wt.event.Action Event evt) {
              // TODO add your handling code here:
              LicenseFrame license=License Frame.getobject ();
              if(license.Chec kLicenseKey())
              {

              /*
              *The following methods are used to redate the values for the next play action
              */
              _usersign.Repai ntjTable();
              currentlog.Clea rCurrentLog();
              comresult.Repai ntjTable();
              logupdate.Clear TextArea();
              trace.AppendLog (GetLogTime.Get Time()+": TibMainPage"+"S tarted");
              CreateLogDir creatdir=new CreateLogDir();
              //This initialisation is for reassign the static value
              TibSignOnPage.e nablestoplink=1 ;
              threadlist=new ArrayList();

              // int sessionnumber= TreeViewDesign. Session_no;
              // System.out.prin tln("sessionnum ber:"+sessionnu mber);

              Runnable runnable = new Runnable() {
              public void run() {
              InvokeLaterMeth od();
              }
              };

              SwingUtilities. invokeLater(run nable);
              for(int usercount=1;use rcount<TreeView Design.Totaluse r+1;usercount++ ) {
              for(int sessionid=0;ses sionid<sessionn umber;sessionid ++) {
              String filename="";

              filename=Double .toString((( TreeViewDesign. Totaluser-(TreeViewDesign .Totaluser%(jav a.lang.Math.pow (10,(Integer.to String(TreeView Design.Totaluse r).length()-1)))))*10)+user count);
              filename=filena me.substring(0, filename.length ()-2);
              filename=filena me.substring(1, filename.length ());
              // System.out.prin tln("filepath:" +TreeViewDesign .directorypath+ "/"+TreeViewDesig n.prefix+"_"+fi lename+".xml");
              TibSignOnPage signon=new TibSignOnPage(T reeViewDesign.d irectorypath+"/"+TreeViewDesig n.prefix+"_"+fi lename+".xml",S top,PlayLink,Pa useLink);
              signon.setName( TreeViewDesign. prefix+"_"+file name);
              signon.start();
              threadlist.add( signon);



              // _usersign.Updat eTable(TreeView Design.prefix+" _"+filename,"Co nnected",sessio nnumber);
              trace.AppendLog (GetLogTime.Get Time()+": TibMainPage"+Tr eeViewDesign.pr efix+"_"+filena me+"Started");
              try
              {
              Thread.sleep(Tr eeViewDesign.Th readtime);
              }
              catch(Exception ex)
              {
              ex.printStackTr ace();
              }
              }
              }

              PlayLink.setEna bled(false);
              Resume.setEnabl ed(false);
              PauseLink.setEn abled(true);
              Stop.setEnabled (true);
              }
              else
              {
              System.out.prin tln("license expired");
              }
              }

              i think the code is hard to understand,ok let me explain some think here where i get struck,
              inside the for loop i am starting the thread class like this
              for()
              {
              //thread start method
              here i am updating the jtable for each increment!!!!
              }[/CODE]
              what will happen here is,until the for loop exits the updation will not happen.is it correct? i am want to update the table inside the for loop inself.how to do that?
              Can you understand the problem?
              Last edited by r035198x; Sep 18 '07, 01:33 PM. Reason: added code tags

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Are you sure it's not updating after adding the data?
                If you're sure then you can call the resizeAndRepain t method of the JTable.

                Comment

                • NagarajanS
                  New Member
                  • Dec 2006
                  • 39

                  #9
                  i tried that but no use.Any other option?
                  ok let me know how will you update any of the control which is inside the while loop?
                  Regards
                  Nags

                  Comment

                  • NagarajanS
                    New Member
                    • Dec 2006
                    • 39

                    #10
                    Thanks all your reply.I got the answer.I used SwingWorker class which is working fine.This is the thing i want.Once again thank you very much mights
                    Regards,
                    Nags.

                    Comment

                    Working...