Solved

A Dialog

Posted on 1998-11-14
5
255 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
[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
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 265
Java Eclipse Loop 3 49
Where to place postgres JDBC driver jar on tomcat 8 71
Java ArrayList and if statement 2 55
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 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

751 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