Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

dialog problem

Thread view: 
cmk128@hotmail.com - 14 May 2006 04:17 GMT
Hi
   when a jframe show a modal jdialog and that jdialog show another
modalness jdialog. The modalness dialog is un-close-able, how to avoid
it?

thanks
from Peter (cmk128@hotmail.com)
Knute Johnson - 14 May 2006 04:44 GMT
> Hi
>     when a jframe show a modal jdialog and that jdialog show another
[quoted text clipped - 3 lines]
> thanks
> from Peter (cmk128@hotmail.com)

Peter:

I don't see your problem with my test code.  Please post a compilable
example that demonstrates your problem.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class test7 {
    public static void main(String[] args) {
        Runnable r = new Runnable() {
            public void run() {
                final JFrame f = new JFrame("test7");
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                JButton b = new JButton("Open Modal Dialog");
                b.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        final JDialog modalDialog = new
JDialog(f,"Modal",true);
                        JButton b = new JButton("Open Non-Modal Dialog");
                        b.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {
                                JDialog nonModalDialog =
                                 new
JDialog(modalDialog,"Non-Modal",false);
                                JLabel l = new JLabel("Non-Modal Dialog");
                                nonModalDialog.add(l);
                                nonModalDialog.pack();
                                nonModalDialog.setVisible(true);
                            }
                        });
                        modalDialog.add(b);
                        modalDialog.pack();
                        modalDialog.setVisible(true);
                    }
                });
                f.add(b);
                f.pack();
                f.setVisible(true);
            }
        };
        EventQueue.invokeLater(r);
    }
}

Signature

Knute Johnson
email s/nospam/knute/

cmk128@hotmail.com - 15 May 2006 03:19 GMT
Hi Johnson
 I fixed the problem, because i was calling the method like this:
new JDialog().setVisible(true);

If i change to this
new JDialog(this).setVisible(true);

It will be fixed.
thanks


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.