Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

event thread dispathing ??

1 view
Skip to first unread message

Lee Young Kyoung

unread,
Mar 15, 2002, 8:04:23 PM3/15/02
to
hi all~~

some of thing processing data with a lot of time..

so i hope show this " Wait a minute " with popup(Jdialog, JFrame,
JOptionPane..etc)

but my popup window is too late or not work until finish data processing.

but run with SwingUtilities.invokeLater() after all data process done ..

and run width SwingUitlities.invokeAndWait() with Exception message

"Exception occurred during event dispatching:
java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
at java.awt.EventQueue.invokeAndWait(EventQueue.java:534)
at
javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1146)
at ServiceVolume$1.actionPerformed(ServiceVolume.java:101)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:14
50)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1504)
"

so...please help me .. let me know reference, web site, some grammer
..etc..


Jon A. Cruz

unread,
Mar 16, 2002, 11:47:49 AM3/16/02
to
Lee Young Kyoung wrote:

> hi all~~
>
> some of thing processing data with a lot of time..
>
> so i hope show this " Wait a minute " with popup(Jdialog, JFrame,
> JOptionPane..etc)
>
> but my popup window is too late or not work until finish data processing.
>
> but run with SwingUtilities.invokeLater() after all data process done ..
>
> and run width SwingUitlities.invokeAndWait() with Exception message
>
> "Exception occurred during event dispatching:
> java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread

That error means pretty much exactly what it says. invokeAndWait needs to be
called from a _different_ thread from your UI.

Here's the general flow of things:

1) User clicks on a button.
2) actionPerformed gets called for your code
3) in your handler, you create a new runnable that has your long operation in
it.
4) in your handler, create a new thread with that runnable and start it.
5) in your handler, throw up a new dialog
6) in your _runnable_, perform your long operation.
7) in your runnable, call invokeLater to update and/or conclude your dialog.

Here's a lesson on threads from The Java Tutorial:
http://java.sun.com/docs/books/tutorial/essential/threads/index.html

--
Jon A. Cruz

"Can't a man even clean up his work area without inadvertently conjuring
up a pack of lightning-breathing ocelots?" - Edward Whitson

0 new messages