Solved

Modal dialog stops method finishing.

Posted on 2007-04-10
5
166 Views
Last Modified: 2010-03-31
Hi,

I'm creating a JDialog that is modal, however it seems that anything after the setVisible(true) prevents the rest of the method finishing. I'm populating a list box, but would like to do it once the dialog is visible (so that error messages appear more in connection with what is displayed), but the function that populates the list box does not get called after the setVisible(true). Possible work arounds?

Thanks,
Uni
0
Comment
Question by:Unimatrix_001
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
The 'setVisible()' hands control over to the dialog until the dialog code say's 'setVisible(false)'.
Then, and no earlier, your method continues.
In between only the dialog buttons can put it to work.
Usually the constructor of a dialog takes up all the data.
I presume the ListBox is displayed in the dialog?
Then do the buildup entirely in the dialog's constructor.

;JOOP!
0
 
LVL 3

Author Comment

by:Unimatrix_001
Comment Utility
"I presume the ListBox is displayed in the dialog?"
Correct.

"Then do the buildup entirely in the dialog's constructor."
The problem with reading in the data before setVisible(true) is called, is that if there is a problem a message box is shown, but it would appear before the dialog is shown. So the message box appears disconnected from the contents of the dialog box.

Is there anyway to get the readData function called inbetween the dialog being shown and control being passed over to the buttons?
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
Comment Utility
I don't see the problem to pop the messagebox from the constructor, where the data is available.
There is a way to 'activate' code in a dialog after the setvisible, by starting a 1-shot timer
from the constructor with a delay of 1 mSec, but maybe that's not what you want.


;JOOP!
0
 
LVL 3

Author Comment

by:Unimatrix_001
Comment Utility
Very well. I'll leave it be. :)
0
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
:-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now