UI freezes for a time consuming operation

Hi,
I'm writing a small plugin which uses a time consuming operation. The problem is that when this operation occurs the UI freezes. I tried do display a Window BEFORE the time consuming operation begins but I'm getting just a grey rectangle and the content of the window is shown AFTER the operation completes. In general my actions are :

public void actionPerformed(AnEvent event) {
.......
dispayMyWindow();
doTimeConsumingOperation();
.......
}

What I'm doing wrong? actionPerformed() method is already executed in EventDispatchingThread. Any idea how can I fix this?

Thanks

3 comments
Comment actions Permalink

Hi,

You may need another thread to do the work (e.g.
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html#SwingWorker).

Valentin Pascaru wrote:

Hi,
I'm writing a small plugin which uses a time consuming operation. The problem is that when this operation occurs the UI freezes. I tried do display a Window BEFORE the time consuming operation begins but I'm getting just a grey rectangle and the content of the window is shown AFTER the operation completes. In general my actions are :

public void actionPerformed(AnEvent event) {
......
dispayMyWindow();
doTimeConsumingOperation();
......
}

What I'm doing wrong? actionPerformed() method is already executed in EventDispatchingThread. Any idea how can I fix this?

Thanks



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

I tried witht the SwingWorker class but the result is the same :(. I'm out of ideas right now.

0
Comment actions Permalink

A small rectification. The result is the same as long the SwingWorker's 'get' method is called. If I remove this method (which seems that blocks the execution until the worker thread ends its execution) everything is fine. But if I remove this how will I know what is the result of the operation and when the worker thread completes its operation?

Thanks

0

Please sign in to leave a comment.