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 / GUI / December 2004

Tip: Looking for answers? Try searching our database.

Example Modal Dialog Problem

Thread view: 
Cliff - 14 Dec 2004 16:20 GMT
// Trying to 1) create a modal dialog 2) launch a dialog from that
modal
// dialog 3) modify the original modal dialog based on an event on the
new
// dialog ... the new dialog however freezes, if the first dialog is
NOT modal
// then this code works as I'm intending... BUT I need the first dialog
to be
// modal... any ideas?

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

public class DialogTest extends JDialog implements ActionListener {

JTextArea t=new JTextArea("This is some text.");
JButton b=new JButton("Open New Dialog");

/** Creates a new instance of DialogTest */
public DialogTest() {
b.addActionListener(this);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(t);
getContentPane().add(b);
setSize(100,100);
}

public static void main(String[] args)
{
DialogTest t=new DialogTest();

// REMOVE setModal(true) and this code works...
t.setModal(true);
t.show();
}

public void actionPerformed(ActionEvent e) {
if(e.getSource()==b)
{
// launch another dialog that attempts to modify the original dialog
JDialog jd=new JDialog();
JButton jb=new JButton("Change Text Area");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev)
{
t.setText("Text Changed");
}
});
jd.getContentPane().add(jb);
jd.setSize(200,75);
            jd.show();
        }
    }   
}
Andrei Kouznetsov - 15 Dec 2004 10:04 GMT
JDialog jd=new JDialog(this);

the new dioalog shold have your modal dialog as owner

Signature

Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities



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.