?
Solved

Modal dialog stops method finishing.

Posted on 2007-04-10
5
Medium Priority
?
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 18887594
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
ID: 18887641
"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 2000 total points
ID: 18887669
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
ID: 18887675
Very well. I'll leave it be. :)
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18887680
:-)
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 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