I'm not working with applets. In an application You can do the following
Button1ActionPerformed (ActionEvent evt) {
Runnable afterRunner = new Runnable() {
public void run() {
// do button operation
// SHORT PROCESSING else GUI is blocked
}
};
Runnable runner = new Runnable() {
public void run() {
try {
// HEAVY BACKGROUND PROCESSING
// Put the button operation runnable on the
event queue
SwingUtilities.invokerLater(afterRunner);
} catch(Exception e){
System.out.println(e);
}
}
//RETURN FASTLY CONTROL
}
-----Original Message-----
From: Jose Antonio Lamas [mailto:[EMAIL PROTECTED]]
Sent: Dienstag, 12. Juni 2001 10:45
To: Ajit Bhingarkar x5495
Cc: Advanced-Swing
Subject: RE: Threads inside actionPerformed event
Hi again,
I'm using JDK 1.3, and the problem is that the "actionPerformed" event
blocks the GUI and I can't do anything else.
I've tried with invokeLater(), and also invokeLater() within another created
thread inside the "actionPerformed" event, but the GUI is freezed until the
event is consumed.
Any solution??
Thanks
> -----Mensaje original-----
> De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]En
> nombre de Ajit Bhingarkar x5495
> Enviado el: lunes 11 de junio de 2001 21:26
> Para: Jose Antonio Lamas
> CC: Advanced-Swing
> Asunto: Re: Threads inside actionPerformed event
>
>
> Jose,
>
> Which JDK are you using ?
> invokeLater() is available from even dispatch thread.
> Following is an exerpt from JavaDoc of invokeLater().
>
> If invokeLater is called from the event dispatching thread -- for
> example, from
> a
> Button's ActionListener -- the doRun.run() will still be deferred
> until all
> pending
> events have been processed. Note that if the doRun.run() throws
> an uncaught
> exception the event dispatching thread will unwind (not the
> current thread).
>
>
> Anyway, if you want your thread to return control to even thread after
> heavy background processing, you can use thread.join().
> But then, what's the use of using threading ?
>
> - Ajit
>
> Jose Antonio Lamas wrote:
>
> > Hi,
> >
> > I would like to know if there is any way to run a thread inside an
> > "actionPerformed" event. The point is to return the control
> after the button
> > is pressed while the created thread is doing a background job.
> The applet
> > runs the thread but doesn't return the control, and "invokeLater" is not
> > available inside the event.
> >
> > Example:
> >
> > jButton1ActionPerformed (java.awt.event.ActionEvent evt)
> >
> > Runnable runner = new Runnable() {
> > public void run() {
> > try {
> > // HEAVY BACKGROUND PROCESSING
> > } catch(Exception e){
> > System.out.println(e);
> > }
> > }
> >
> > //RETURN FASTLY CONTROL
> >
> > }
> >
> > Thanks
> >
> > _______________________________________________
> > Advanced-swing mailing list
> > [EMAIL PROTECTED]
> > http://eos.dk/mailman/listinfo/advanced-swing
>
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing