Solved

A Dialog

Posted on 1998-11-14
5
240 Views
Last Modified: 2010-03-30
When a user clicks a button, a dialog is shown. I don't
want to let the user do anything on the parent frame before
the user closes the dialog. What should I do?
Please also lock the following question:
http://www.experts-exchange.com/topics/bin/Q.10097531

Thank!
0
Comment
Question by:leeann
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
conick earned 0 total points
ID: 1227427
you need to make the dialog "modal"

you can do this with the Dialog constructor when you open your dialog
like this:

Dialog dlg= new Dialog(owner_frame,true);

Let me know if you need more information


0
 
LVL 7

Expert Comment

by:conick
ID: 1227428
you can also set a dialog "modal" that is already up by calling the method:

dlg.setModal(true);

0
 

Author Comment

by:leeann
ID: 1227429
Hi, Conick:
I have tried your codes, but I found there was a problem. Here is a piece
of my codes:
 public void actionPerformed(ActionEvent e)
     {  
        if (e.getSource() == btnCustom){
           //QueryDialog extends Dialog
            QueryDialog queryd = new QueryDialog(this,true);                    
            queryd.setModal(true);
            queryd.show();
            try{
               doQuery();
               more = rs.next();
               if(more)
                  showResultSet(rs, queryd);  //displays the  rs on the text area
                                                                       // in the QueryDialog queryd        
             }catch(Exception ex){
               System.out.println(ex);
            }
                       
         }
   }

The above codes looks work, but it can not display the result set rs of a
SQL on the text area in the QueryDialog queryd. If I put the code:
    queryd.setModal(true);  after the code:  queryd.show();  , It can not
display the result set rs of a SQL on the text area in the QueryDialog
queryd, but the user can do anything on the parent frame before
closes the dialog. Could you please tell me how to solve this problem?  
           

0
 

Author Comment

by:leeann
ID: 1227430
Sorry, I make a mistake in the last comment. It should be:
 If I put the code:  queryd.setModal(true);  after the code:  queryd.show();  , It can display the result set rs of a SQL on the text area in the QueryDialog
queryd, but the user can do anything on the parent frame before closes the dialog.   
           
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227431
maybe its better to put all the following code inside the Dialog class
and from outside just call queryd.setModal(true);

    try{
                     doQuery();
                     more = rs.next();
                     if(more)
                        showResultSet(rs, queryd);  //displays the  rs on the text area
                                                                             // in the QueryDialog queryd        
                   }catch(Exception ex){
                     System.out.println(ex);
                  }


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

932 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

12 Experts available now in Live!

Get 1:1 Help Now