JDK-4148453 : Two separate JFrames cannot co-exist
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-06-12
  • Updated: 2000-03-15
  • Resolved: 2000-03-15
Related Reports
Duplicate :  
Description

Name: el35337			Date: 06/12/98


Create two separate JFrames.  A modal dialog
appears in front of jframe1.  You cannot access
jframe2 because somehow the modal dialog is 
associated with jframe2.  With this bug, you 
cannot really have two separate jframes that 
co-exist in one JVM.

I sent this to Java_AWT first, and Jukka Tammisto
told me to report this to swing instead of there.
Source code to make problem below.

import com.sun.java.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;

public class f extends JFrame
{    
    public f()    {
        setSize(getInsets().left + getInsets().right + 400, getInsets().top + getInsets().bottom + 400);
        Container c = getContentPane();
        c.setLayout(null);
        
        Button b = new Button();
        b.setBounds(20, 20, 100, 100);
        b.setLabel("Show Dialog");
        c.add(b);        
        b.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e)
                                {
                                    MyJDialog d = new MyJDialog(f.this);
                                    d.show();                                    
                                }
                            });
                            
        addWindowListener(new WindowAdapter() {
                                public void windowClosing(WindowEvent e)
                                {
                                    System.exit(0);                                                                                                               
                                }
                            });                                                        
    }
    
    public static void main(String[] a)
    {
        f f1 = new f();
        f f2 = new f();
        f1.setLocation(0,0);
        f2.setLocation(400,0);                
        f1.show();
        f2.show();
    }    

    class MyJDialog extends JDialog 
    {
        JTextField t;
        public MyJDialog(JFrame myFrame) 
        {
            super(myFrame, true);
            
            final JFrame frame = myFrame;
            setSize(getInsets().left + getInsets().right + 300, getInsets().top + getInsets().bottom + 100);
            setLocation(150,400);
        }                                
        
    }
}
(Review ID: 33580)
======================================================================

Comments
WORK AROUND Name: el35337 Date: 06/12/98 Don't create two JFrames in one JVM ======================================================================
11-06-2004

EVALUATION Swing's JDialog inherits modal functionality directly from java.awt.Dialog, so in fact this IS an AWT issue. There is already another bug which covers this issue: 4080029. amy.fowler@Eng 2000-03-15
15-03-2000