473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

java eqivalent for Application.DoEvents()

Hi,
can any one tell me the eqivalent for Application.DoEvents() in java.I am swing application so i need to do this to elimate the hangling of my application.
Regards,
nags.
Sep 18 '07 #1
9 14913
r035198x
13,262 8TB
Hi,
can any one tell me the eqivalent for Application.DoEvents() in java.I am swing application so i need to do this to elimate the hangling of my application.
Regards,
nags.
What does Application.DoEvents() do?
Sep 18 '07 #2
Application.DoEvents() 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.DoEvents()" inside the loop.
Sep 18 '07 #3
r035198x
13,262 8TB
Application.DoEvents() 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.DoEvents()" inside the loop.
Why don't you post the Java code that you have and explain the problem you are getting in the code.
Sep 18 '07 #4
questionit
553 512MB
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

Why don't you post the Java code that you have and explain the problem you are getting in the code.
Sep 18 '07 #5
r035198x
13,262 8TB
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.
Sep 18 '07 #6
here is the code,
Expand|Select|Wrap|Line Numbers
  1.  private void PlayLinkActionPerformed(java.awt.event.ActionEvent evt) {                                         
  2. // TODO add your handling code here:
  3.         LicenseFrame license=LicenseFrame.getobject();
  4.        if(license.CheckLicenseKey())
  5.        {
  6.  
  7.        /*
  8.         *The following methods are used to redate the values for the next play action
  9.         */
  10.         _usersign.RepaintjTable();
  11.         currentlog.ClearCurrentLog();
  12.         comresult.RepaintjTable();
  13.         logupdate.ClearTextArea();
  14.         trace.AppendLog(GetLogTime.GetTime()+": TibMainPage"+"Started");
  15.         CreateLogDir creatdir=new CreateLogDir();
  16.         //This initialisation is for reassign the static value
  17.         TibSignOnPage.enablestoplink=1;
  18.         threadlist=new ArrayList();
  19.  
  20.       //  int sessionnumber= TreeViewDesign.Session_no;
  21.        // System.out.println("sessionnumber:"+sessionnumber);
  22.  
  23.         Runnable runnable = new Runnable() {
  24.          public void run() {
  25.          InvokeLaterMethod();
  26.              }
  27.             };
  28.  
  29.         SwingUtilities.invokeLater(runnable);
  30.        for(int usercount=1;usercount<TreeViewDesign.Totaluser+1;usercount++) {
  31.             for(int sessionid=0;sessionid<sessionnumber;sessionid++) {
  32.                 String filename="";
  33.  
  34.                filename=Double.toString((( TreeViewDesign.Totaluser-(TreeViewDesign.Totaluser%(java.lang.Math.pow(10,(Integer.toString(TreeViewDesign.Totaluser).length()-1)))))*10)+usercount);
  35.                filename=filename.substring(0,filename.length()-2);
  36.                filename=filename.substring(1,filename.length());
  37.              // System.out.println("filepath:"+TreeViewDesign.directorypath+"/"+TreeViewDesign.prefix+"_"+filename+".xml");
  38.                TibSignOnPage signon=new TibSignOnPage(TreeViewDesign.directorypath+"/"+TreeViewDesign.prefix+"_"+filename+".xml",Stop,PlayLink,PauseLink);
  39.                signon.setName(TreeViewDesign.prefix+"_"+filename);
  40.                signon.start();
  41.                threadlist.add(signon); 
  42.  
  43.  
  44.  
  45.                // _usersign.UpdateTable(TreeViewDesign.prefix+"_"+filename,"Connected",sessionnumber);
  46.                 trace.AppendLog(GetLogTime.GetTime()+": TibMainPage"+TreeViewDesign.prefix+"_"+filename+"Started");
  47.                 try
  48.                 {
  49.                 Thread.sleep(TreeViewDesign.Threadtime);
  50.                 }
  51.                 catch(Exception ex)
  52.                 {
  53.                     ex.printStackTrace();
  54.                 }
  55.             }
  56.         }
  57.  
  58.         PlayLink.setEnabled(false);
  59.         Resume.setEnabled(false);
  60.         PauseLink.setEnabled(true);
  61.         Stop.setEnabled(true);
  62.        }
  63.        else
  64.        {
  65.             System.out.println("license expired");
  66.        }
  67.     }   
  68.  
  69. i think the code is hard to understand,ok let me explain some think here where i get struck,
  70. inside  the for loop i am starting the thread class like this
  71. for()
  72. {
  73. //thread start method
  74. here i am updating the jtable for each increment!!!! 
  75. }
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?
Sep 18 '07 #7
r035198x
13,262 8TB
Are you sure it's not updating after adding the data?
If you're sure then you can call the resizeAndRepaint method of the JTable.
Sep 18 '07 #8
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
Sep 21 '07 #9
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.
Sep 21 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: bazad | last post by:
Hi, I'd like to understand consequences of Application.DoEvents call. Does it create a new thread? Thank you
6
by: foldface | last post by:
Hi I am doing drag and drop between controls (listview and treeview) using mouse_event. What I am after is a book/resource to explain the behaviour below. If I do the various Win32 api calls...
6
by: Ollie Riches | last post by:
I understand the use of Application.DoEvents() to process all outstanding messages on the message queue in a winforms application if you have long running process on the UI thread. But can anyone...
1
by: RSH | last post by:
I created a new Windows Form project and I created a simple richtextbox to write to and I am looping through a simple example but obviously the screen isn't updated it only shows the first...
13
by: Amjad | last post by:
Hi, Is there an equivalent to the "Application.Doevents" method in modules or Windows services? I want to make a Windows service that calls a DLL. The DLL would have all my functions and it...
2
by: joeforbroke | last post by:
Background: I am helping someone debug a problem with their form that I have traced to a strange interaction between a click event handler and Application.DoEvents(). I'm trying to talk him into...
5
by: james.jdunne | last post by:
System.ArgumentException: Item has already been added. Key in dictionary: "-1" Key being added: "-1" at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at...
16
by: Alan T | last post by:
I tried to use a thread to process a iterative execution of processes but afraid my thread is not thread-safe. If I am not using a thread, my main form will become 'white' when switch forth and...
4
by: Woo Mun Foong | last post by:
Hi, I have a DLL that is used to carry out some lengthly process. I would like to have something similar to DoEvents that can yield control back to Windows every now and then. Any ideas ? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.