• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDialog suspending while setVisible(true)

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about the JDialog.

What I need to do is to show the JDialog (because I need the window to be modal) with a lable saying "Please wait while loading information." While the information continues to load. When the information is loaded, I need the lable to be removed and a JTable to be shown.

What I have found is that after I call setVisible(true) to the dialog, I can't seem to do anything else with it until I click close.

I've read on the net that displaying a modal dialog will block input to the top level windows and will block the thread that calls setVisible(true).

So how can I accomplish removing and adding components without having the user need to click the close button?

Thanks,
Rachel
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to call jdialog.setVisible() from a different thread than the one you do processing in.
 
Liang Anmian
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely. Either use another thread to show the dialog, or process what you need in another thread.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is to use the SwingWorker class. Requires SwingWorker.java.

[ July 23, 2004: Message edited by: Craig Wood ]
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Looks like that is what I'll do. I'll give that a try.

Cheers,
Rachel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!