473,385 Members | 2,014 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,385 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 14924
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.