Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4148453

Two separate JFrames cannot co-exist

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                amfowler Anne Fowler (Inactive)
                Reporter:
                elarsen Erik Larsen (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: