Non-blocking modal Swing progress dialog -


a daft question, cannot work: have long-running process in swing application may take several minutes. want display progress dialog user while process ongoing. want prevent user performing further actions, eg pressing button while process going on.

if process on edt, prevents end-user doing while process going on. because edt busy processing, never gets around rendering dialog's content, outline of dialog.

but if process in worker thread, end-user can click buttons , cause edt manipulate state worker manipulating @ same time, bad stuff consequence. if make dialog modal, not happen, modal in swing implies blocking, moment call setvisible(true), thread blocks forever.

so current "solution" use worker thread, , spawn off separate thread purpose absorb blocking nature of setvisible. surely there must better solution!

so how dialog prevents user interacting rest of system (modal) not block thread causes visible?

you should using glasspane preventing user interacting. thing modal user , not program thread won't blocked.

the great news can use cool gui effects shading gui portion busy , user can't interact with. can display busy gif image in glasspane.

links:-

  1. official tutorial on glasspane
  2. some helpful tutorials
  3. another tut
  4. oreilly's swing hacks excellent.

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -