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

dialog opened from another dialog disables to close original one

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1
    • client-libs
    • None
    • x86
    • windows_nt



      Name: mc57594 Date: 01/10/97

      When modal dialog is opened from another modal dialog it is
      impossible to
      close the first one later and the application gets into the deadlock.
      Source code follows:

      // Example - Two Dialogs open

      import java.awt.*;
      import java.awt.event.*;


      // Main frame
      public class DialogTest extends Frame implements ActionListener {

          public static void main(String[] args) {
              new DialogTest().show();
          }

          public DialogTest() {
              MenuBar menubar = new MenuBar();
              Menu menu = new Menu("Dialog");
              menu.add(new MenuItem("Open..."));
              menu.addSeparator();
              menu.add(new MenuItem("Exit"));
              for (int i=0; i < menu.getItemCount(); i++)
                  menu.getItem(i).addActionListener(this);
              menubar.add(menu);
              setMenuBar(menubar);
              resize(300,200);
          }

          public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand().equals("Open...")) {
                  Dialog d = new FirstDialog(this);
                  d.show();
                  d.dispose();
              }
              if (e.getActionCommand().equals("Exit")) {
                  dispose();
                  System.exit(0);
              }
          }
      }

      // First dialog
      class FirstDialog extends Dialog implements ActionListener {
          Button ok;
          Button next;
          Frame frame;

          public FirstDialog(Frame frame) {
              super(frame,"First Dialog",true);
              this.frame = frame;
              ok = new Button(" OK ");
              ok.addActionListener(this);
              next = new Button(" Next ");
              next.addActionListener(this);
              Panel panel = new Panel();
              panel.add("West",ok);
              panel.add("East",next);
              add("South",panel);
              resize(150,70);
          }

          public void actionPerformed(ActionEvent e) {
              if (e.getSource() == next) {
                  Dialog d = new SecondDialog(frame);
                  d.show();
                  d.dispose();
              }
              if (e.getSource() == ok)
                  hide();
          }

      }

      class SecondDialog extends Dialog implements ActionListener {
          Button ok;

          public SecondDialog(Frame frame) {
              super(frame,"Second Dialog",true);
              ok = new Button(" OK ");
              ok.addActionListener(this);
              add("South",ok);
              resize(100,70);
          }

          public void actionPerformed(ActionEvent e) {
              if (e.getSource() == ok)
                  hide();
          }
      }

      ======================================================================

            Unassigned Unassigned
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: