RE: suspend the awt thread

2003-06-12 Thread Deblauwe, Wim
Title: suspend the awt thread



true, 
but what if it is not possible to do all operations in the 
Runnable?

  -Original Message-From: Sachin Hejip 
  [mailto:[EMAIL PROTECTED]Sent: woensdag 11 juni 2003 
  9:50To: Deblauwe, WimSubject: Re: suspend the awt 
  thread
  Do all your operations inside the runnable - finish off the 
  whole task inside the run method.
  
- Original Message - 
From: 
Deblauwe, Wim 
To: 'Sachin Hejip' 
Sent: Wednesday, June 11, 2003 1:17 
PM
Subject: RE: suspend the awt 
thread

But after the call:
 
new Thread(runnable).start();
 
I 
need to wait for the new Thread to finish, because I want to get some object 
from that runnable and it will only be available when the run() is 
completed.
 
I 
tried with:
 
while( thread.isAlive() )
{
    Thread.sleep(300);
}
 
but this sleeps the awt thread, so no painting happens 
anymore
 

  -Original Message-From: Sachin Hejip 
  [mailto:[EMAIL PROTECTED]Sent: woensdag 11 juni 2003 
  9:07To: Sachin Hejip; Deblauwe, Wim; 
  [EMAIL PROTECTED]Subject: Re: suspend the awt 
  thread
  Sorry, since the dialog is modal you need to show it in 
  the run of the runnable (again in the SwingUtilities and not in the 
  actionPerformed). 
   
  
  public void actionPerformed(ActionEvent ae) 
  {
      Runnable runnable = new Runnable() 
  {
          public void run() 
  {
              
  startProgressDialog(); // remember to do this in the swing 
  thread    
  try {            
      // do some long operation and update progress dialog in 
  the Swing thread when appropriate
              
  } finally {
              
      closeProgressDialog(); // remember to do this in the 
  swing thread
          }
      }
      new 
  Thread(runnable).start();
  }
  
- Original Message - 

From: 
Sachin 
Hejip 
To: Deblauwe, Wim ; [EMAIL PROTECTED] 
Sent: Wednesday, June 11, 
2003 12:33 PM
Subject: Re: suspend the 
    awt thread

Yes, create the dialog and start the progress bar in 
the action peformed and then update it with calls to 
SwingUtilities.invokeLater in your MyRunnable class. Make sure you close 
the dialog in a finally block.
 
 

Hope this helps.
Regards
Sachin
 

  - Original Message - 
  
  From: 
  Deblauwe, Wim 
  To: 'Sachin 
  Hejip' ; [EMAIL PROTECTED] 
  Sent: Wednesday, June 
  11, 2003 12:18 PM
      Subject: RE: suspend the 
  awt thread
  
  Yes, a) is what I want to do. Now the 
  progressbar is started in the MyRunnable() class. Are you saying that 
  I should start it within the actionPerformed() 
  method?
  
-Original Message-From: Sachin Hejip 
[mailto:[EMAIL PROTECTED]Sent: woensdag 11 juni 2003 
8:45To: Deblauwe, Wim; [EMAIL PROTECTED]Subject: 
            Re: suspend the awt thread
Sorry - sent it before completing my sentence - I 
meant to say a) seems the best way . :-)

  - Original Message 
  - 
  From: 
  Sachin Hejip 
  To: Deblauwe, Wim ; [EMAIL PROTECTED] 
  
  Sent: Wednesday, 
  June 11, 2003 12:14 PM
      Subject: Re: suspend 
      the awt thread
  
  Hey,
   
  From what I understood what you wish to achieve 
  is that the UI should continue to repaint but the user should not 
  be able to interact with it while you complete your 
  task?
  You can - 
  a) Show a modal dialog that says "Please Wait" 
  or shows a progress bar preferably with a cancel button - this 
  dialog disappears on the completion of your task. (I think this is 
  the 
  b) Disable all input event dispatching until 
  your operation concludes by replacing the EventQueue with your 
  own. 
  c) A harder way to achieve this is to have the 
  glass pane take focus, block mouse events and disable all 
  menus.
   
  Does this help?
   
  Regards
  Sachin
  
- Original Message 
- 
From: 
Deblauwe, Wim 
To: '[EMAIL PROTECTED]' 

Re: suspend the awt thread

2003-06-11 Thread Sachin Hejip
Title: suspend the awt thread



Sorry, since the dialog is modal you need to show it in the 
run of the runnable (again in the SwingUtilities and not in the 
actionPerformed). 
 

public void actionPerformed(ActionEvent ae) {
    Runnable runnable = new Runnable() 
{
        public void run() {
            
startProgressDialog(); // remember to do this in the swing 
thread    
try {            
    // do some long operation and update progress dialog in the 
Swing thread when appropriate
            } 
finally {
            
    closeProgressDialog(); // remember to do this in the swing 
thread
        }
    }
    new Thread(runnable).start();
}

  - Original Message - 
  From: 
  Sachin 
  Hejip 
  To: Deblauwe, Wim ; [EMAIL PROTECTED] 
  Sent: Wednesday, June 11, 2003 12:33 
  PM
  Subject: Re: suspend the awt thread
  
  Yes, create the dialog and start the progress bar in the 
  action peformed and then update it with calls to SwingUtilities.invokeLater in 
  your MyRunnable class. Make sure you close the dialog in a finally 
  block.
   
   
  
  Hope this helps.
  Regards
  Sachin
   
  
- Original Message - 
From: 
Deblauwe, Wim 
To: 'Sachin Hejip' ; [EMAIL PROTECTED] 
Sent: Wednesday, June 11, 2003 12:18 
PM
Subject: RE: suspend the awt 
thread

Yes, a) is what I want to do. Now the progressbar 
is started in the MyRunnable() class. Are you saying that I should start it 
within the actionPerformed() method?

  -Original Message-From: Sachin Hejip 
  [mailto:[EMAIL PROTECTED]Sent: woensdag 11 juni 2003 
  8:45To: Deblauwe, Wim; [EMAIL PROTECTED]Subject: 
  Re: suspend the awt thread
  Sorry - sent it before completing my sentence - I meant 
  to say a) seems the best way . :-)
  
- Original Message - 

From: 
Sachin 
Hejip 
To: Deblauwe, Wim ; [EMAIL PROTECTED] 
Sent: Wednesday, June 11, 
2003 12:14 PM
Subject: Re: suspend the 
    awt thread

Hey,
 
From what I understood what you wish to achieve is 
that the UI should continue to repaint but the user should not be able 
to interact with it while you complete your task?
You can - 
a) Show a modal dialog that says "Please Wait" or 
shows a progress bar preferably with a cancel button - this dialog 
disappears on the completion of your task. (I think this is the 

b) Disable all input event dispatching until your 
operation concludes by replacing the EventQueue with your own. 

c) A harder way to achieve this is to have the glass 
pane take focus, block mouse events and disable all menus.
 
Does this help?
 
Regards
Sachin

  - Original Message - 
  
  From: 
  Deblauwe, Wim 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Wednesday, June 
  11, 2003 11:40 AM
      Subject: suspend the awt 
  thread
  
  Hi, 
      I want to suspend the awt thread but still get 
  painting done. Is this possible? 
  assume this piece of code: 
  actionPerformed(ActionEvent e) {     Runnable myRunnable = new MyRunnable(); 
      Thread 
  workerThread = new Thread( myRunnable ); 
      workerThread.start(); 
      // Wait 
  here for workerThread to finish 
      // but 
  still paint! 
      Oject o = 
  myRunnable.getObject(); 
      // do 
  something with o } 
  You are in the actionPerformed, so this gets executed 
  on the awt thread. The workerThread starts with some lengthy operation 
  and we want to wait in the actionPerformed for it to finish and then 
  continue with our work. How do I do it?
  kind regards, 
  Wim 
  - Ing. Wim 
  Deblauwe Software Development Engineer 
  Medical Imaging Systems - BarcoView 
  - - - - - - - - DISCLAIMER - - - - - - - - 
  Unless indicated otherwise, the 
  information contained in this message is privileged and confidential, 
  and is intended only for the use of the addressee(s) named above and 
  others who have been specifically authorized to receive it. If you are 
  not the intended recipient, you are hereby notified that any 
  dissemination, distribution or copying of this message and/or 
  attachments is strictly prohibited. The company accepts no liability 
  for any damage caused by any virus transmitted by this email. 
  Furthermore, the company does not warrant a proper and complete 
  transmission of this i

Re: suspend the awt thread

2003-06-11 Thread Sachin Hejip
Title: suspend the awt thread



Yes, create the dialog and start the progress bar in the 
action peformed and then update it with calls to SwingUtilities.invokeLater in 
your MyRunnable class. Make sure you close the dialog in a finally 
block.
 
public void actionPerformed(ActionEvent ae) {
    startProgressDialog();
    Runnable runnable = new Runnable() 
{
        public void run() 
{            try 
{                
// do some long operation and update progress dialog in the Swing thread when 
appropriate
            } 
finally {
            
    closeProgressDialog(); // remember to do this in the swing 
thread
        }
    }
    new Thread(runnable).start();
}
 

Hope this helps.
Regards
Sachin
 

  - Original Message - 
  From: 
  Deblauwe, 
  Wim 
  To: 'Sachin Hejip' ; [EMAIL PROTECTED] 
  Sent: Wednesday, June 11, 2003 12:18 
  PM
  Subject: RE: suspend the awt thread
  
  Yes, 
  a) is what I want to do. Now the progressbar is started in the MyRunnable() 
  class. Are you saying that I should start it within the actionPerformed() 
  method?
  
-Original Message-From: Sachin Hejip 
[mailto:[EMAIL PROTECTED]Sent: woensdag 11 juni 2003 
8:45To: Deblauwe, Wim; [EMAIL PROTECTED]Subject: 
Re: suspend the awt thread
Sorry - sent it before completing my sentence - I meant to 
say a) seems the best way . :-)

  - Original Message - 
  From: 
  Sachin 
  Hejip 
  To: Deblauwe, Wim ; [EMAIL PROTECTED] 
  Sent: Wednesday, June 11, 
  2003 12:14 PM
  Subject: Re: suspend the awt 
  thread
  
  Hey,
   
  From what I understood what you wish to achieve is that 
  the UI should continue to repaint but the user should not be able to 
  interact with it while you complete your task?
  You can - 
  a) Show a modal dialog that says "Please Wait" or shows 
  a progress bar preferably with a cancel button - this dialog disappears on 
  the completion of your task. (I think this is the 
  b) Disable all input event dispatching until your 
  operation concludes by replacing the EventQueue with your own. 
  
  c) A harder way to achieve this is to have the glass 
  pane take focus, block mouse events and disable all menus.
   
  Does this help?
   
  Regards
  Sachin
  
- Original Message - 

From: 
Deblauwe, Wim 
To: '[EMAIL PROTECTED]' 
Sent: Wednesday, June 11, 
2003 11:40 AM
    Subject: suspend the awt 
thread

    Hi, 
    I want to suspend the awt thread but still get painting 
done. Is this possible? 
assume this piece of code: 
actionPerformed(ActionEvent e) {     Runnable myRunnable = new MyRunnable(); 
    Thread 
workerThread = new Thread( myRunnable ); 
    workerThread.start(); 
    // Wait here 
for workerThread to finish 
    // but still 
paint! 
    Oject o = 
myRunnable.getObject(); 
    // do 
something with o } 
You are in the actionPerformed, so this gets executed on 
the awt thread. The workerThread starts with some lengthy operation and 
we want to wait in the actionPerformed for it to finish and then 
continue with our work. How do I do it?
kind regards, 
Wim 
- Ing. Wim 
Deblauwe Software Development Engineer 
Medical Imaging Systems - BarcoView - - - - - - - - DISCLAIMER - - - - - - - - 
Unless indicated otherwise, the 
information contained in this message is privileged and confidential, 
and is intended only for the use of the addressee(s) named above and 
others who have been specifically authorized to receive it. If you are 
not the intended recipient, you are hereby notified that any 
dissemination, distribution or copying of this message and/or 
attachments is strictly prohibited. The company accepts no liability for 
any damage caused by any virus transmitted by this email. Furthermore, 
the company does not warrant a proper and complete transmission of this 
information, nor does it accept liability for any delays. If you have 
received this message in error, please contact the sender and delete the 
message. Thank you.
  - - - - - - - - DISCLAIMER - - - - - - - - 
  
  Unless indicated otherwise, the information 
  contained in this message is privileged and confidential, and is intended only 
  for the use of the addressee(s) named above and others who have been 
  specifically authorized to receive it. If you are not the intended recipient, 
  you are hereby notified that any dissemination, distribution or copying of 
  this message and/or attachments is strictly proh

RE: suspend the awt thread

2003-06-10 Thread Deblauwe, Wim
Title: suspend the awt thread



Yes, 
a) is what I want to do. Now the progressbar is started in the MyRunnable() 
class. Are you saying that I should start it within the actionPerformed() 
method?

  -Original Message-From: Sachin Hejip 
  [mailto:[EMAIL PROTECTED]Sent: woensdag 11 juni 2003 
  8:45To: Deblauwe, Wim; [EMAIL PROTECTED]Subject: Re: 
  suspend the awt thread
  Sorry - sent it before completing my sentence - I meant to 
  say a) seems the best way . :-)
  
- Original Message - 
From: 
Sachin 
Hejip 
To: Deblauwe, Wim ; [EMAIL PROTECTED] 
Sent: Wednesday, June 11, 2003 12:14 
PM
Subject: Re: suspend the awt 
thread

Hey,
 
From what I understood what you wish to achieve is that 
the UI should continue to repaint but the user should not be able to 
interact with it while you complete your task?
You can - 
a) Show a modal dialog that says "Please Wait" or shows a 
progress bar preferably with a cancel button - this dialog disappears on the 
completion of your task. (I think this is the 
b) Disable all input event dispatching until your 
operation concludes by replacing the EventQueue with your own. 
c) A harder way to achieve this is to have the glass pane 
take focus, block mouse events and disable all menus.
 
Does this help?
 
Regards
Sachin

  - Original Message - 
  From: 
  Deblauwe, Wim 
  To: '[EMAIL PROTECTED]' 
  Sent: Wednesday, June 11, 2003 11:40 
  AM
      Subject: suspend the awt thread
  
  Hi, 
      I want to suspend the awt thread but still get painting 
  done. Is this possible? 
  assume this piece of code: 
  actionPerformed(ActionEvent e) {     Runnable myRunnable = new MyRunnable(); 
      Thread 
  workerThread = new Thread( myRunnable ); 
      workerThread.start(); 
      // Wait here 
  for workerThread to finish 
      // but still 
  paint! 
      Oject o = 
  myRunnable.getObject(); 
      // do something 
  with o } 
  You are in the actionPerformed, so this gets executed on 
  the awt thread. The workerThread starts with some lengthy operation and we 
  want to wait in the actionPerformed for it to finish and then continue 
  with our work. How do I do it?
  kind regards, 
  Wim 
  - Ing. Wim 
  Deblauwe Software Development Engineer 
  Medical Imaging Systems - BarcoView - - - - - - - - DISCLAIMER - - - - - - - - Unless indicated otherwise, the information contained in this 
  message is privileged and confidential, and is intended only for the use 
  of the addressee(s) named above and others who have been specifically 
  authorized to receive it. If you are not the intended recipient, you are 
  hereby notified that any dissemination, distribution or copying of this 
  message and/or attachments is strictly prohibited. The company accepts no 
  liability for any damage caused by any virus transmitted by this email. 
  Furthermore, the company does not warrant a proper and complete 
  transmission of this information, nor does it accept liability for any 
  delays. If you have received this message in error, please contact the 
  sender and delete the message. Thank 
  you.

- - - - - - - - DISCLAIMER - - - - - - - - 

Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.


Re: suspend the awt thread

2003-06-10 Thread Sachin Hejip
Title: suspend the awt thread



Sorry - sent it before completing my sentence - I meant to say 
a) seems the best way . :-)

  - Original Message - 
  From: 
  Sachin 
  Hejip 
  To: Deblauwe, Wim ; [EMAIL PROTECTED] 
  Sent: Wednesday, June 11, 2003 12:14 
  PM
  Subject: Re: suspend the awt thread
  
  Hey,
   
  From what I understood what you wish to achieve is that the 
  UI should continue to repaint but the user should not be able to interact with 
  it while you complete your task?
  You can - 
  a) Show a modal dialog that says "Please Wait" or shows a 
  progress bar preferably with a cancel button - this dialog disappears on the 
  completion of your task. (I think this is the 
  b) Disable all input event dispatching until your operation 
  concludes by replacing the EventQueue with your own. 
  c) A harder way to achieve this is to have the glass pane 
  take focus, block mouse events and disable all menus.
   
  Does this help?
   
  Regards
  Sachin
  
- Original Message - 
From: 
Deblauwe, Wim 
To: '[EMAIL PROTECTED]' 
Sent: Wednesday, June 11, 2003 11:40 
AM
    Subject: suspend the awt thread

    Hi, 
    I want to suspend the awt thread but still get painting 
done. Is this possible? 
assume this piece of code: 
actionPerformed(ActionEvent e) {     Runnable myRunnable = new MyRunnable(); 
    Thread 
workerThread = new Thread( myRunnable ); 
    workerThread.start(); 
    // Wait here for 
workerThread to finish     
// but still paint! 
    Oject o = 
myRunnable.getObject(); 
    // do something 
with o } 
You are in the actionPerformed, so this gets executed on the 
awt thread. The workerThread starts with some lengthy operation and we want 
to wait in the actionPerformed for it to finish and then continue with our 
work. How do I do it?
kind regards, 
Wim 
- Ing. Wim 
Deblauwe Software Development Engineer 
Medical Imaging Systems - BarcoView - - - - - - - - DISCLAIMER - - - - - - - - Unless indicated otherwise, the information contained in this message 
is privileged and confidential, and is intended only for the use of the 
addressee(s) named above and others who have been specifically authorized to 
receive it. If you are not the intended recipient, you are hereby notified 
that any dissemination, distribution or copying of this message and/or 
attachments is strictly prohibited. The company accepts no liability for any 
damage caused by any virus transmitted by this email. Furthermore, the 
company does not warrant a proper and complete transmission of this 
information, nor does it accept liability for any delays. If you have 
received this message in error, please contact the sender and delete the 
message. Thank you.


Re: suspend the awt thread

2003-06-10 Thread Sachin Hejip
Title: suspend the awt thread



Hey,
 
From what I understood what you wish to achieve is that the UI 
should continue to repaint but the user should not be able to interact with it 
while you complete your task?
You can - 
a) Show a modal dialog that says "Please Wait" or shows a 
progress bar preferably with a cancel button - this dialog disappears on the 
completion of your task. (I think this is the 
b) Disable all input event dispatching until your operation 
concludes by replacing the EventQueue with your own. 
c) A harder way to achieve this is to have the glass pane take 
focus, block mouse events and disable all menus.
 
Does this help?
 
Regards
Sachin

  - Original Message - 
  From: 
  Deblauwe, 
  Wim 
  To: '[EMAIL PROTECTED]' 
  Sent: Wednesday, June 11, 2003 11:40 
  AM
  Subject: suspend the awt thread
  
  Hi, 
  I want to suspend the awt thread but still get painting done. 
  Is this possible? 
  assume this piece of code: 
  actionPerformed(ActionEvent e) {     Runnable myRunnable = new MyRunnable(); 
      Thread 
  workerThread = new Thread( myRunnable ); 
      workerThread.start(); 
      // Wait here for 
  workerThread to finish     
  // but still paint! 
      Oject o = 
  myRunnable.getObject(); 
      // do something 
  with o } 
  You are in the actionPerformed, so this gets executed on the 
  awt thread. The workerThread starts with some lengthy operation and we want to 
  wait in the actionPerformed for it to finish and then continue with our work. 
  How do I do it?
  kind regards, 
  Wim 
  - Ing. Wim Deblauwe 
  Software Development Engineer Medical 
  Imaging Systems - BarcoView - - - - - - - - 
  DISCLAIMER - - - - - - - - Unless indicated 
  otherwise, the information contained in this message is privileged and 
  confidential, and is intended only for the use of the addressee(s) named above 
  and others who have been specifically authorized to receive it. If you are not 
  the intended recipient, you are hereby notified that any dissemination, 
  distribution or copying of this message and/or attachments is strictly 
  prohibited. The company accepts no liability for any damage caused by any 
  virus transmitted by this email. Furthermore, the company does not warrant a 
  proper and complete transmission of this information, nor does it accept 
  liability for any delays. If you have received this message in error, please 
  contact the sender and delete the message. Thank 
you.


suspend the awt thread

2003-06-10 Thread Deblauwe, Wim
Title: suspend the awt thread





Hi,


I want to suspend the awt thread but still get painting done. Is this possible?


assume this piece of code:


actionPerformed(ActionEvent e)
{
    Runnable myRunnable = new MyRunnable();
    Thread workerThread = new Thread( myRunnable );
    workerThread.start();


    // Wait here for workerThread to finish
    // but still paint!


    Oject o = myRunnable.getObject();


    // do something with o
}


You are in the actionPerformed, so this gets executed on the awt thread. The workerThread starts with some lengthy operation and we want to wait in the actionPerformed for it to finish and then continue with our work. How do I do it?

kind regards,


Wim


-
Ing. Wim Deblauwe
Software Development Engineer
Medical Imaging Systems - BarcoView
- - - - - - - - DISCLAIMER - - - - - - - - 
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.