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

can't hide modal dialog

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1
    • client-libs
    • None
    • x86
    • windows_95



      Name: el35337 Date: 01/14/97

      when a modal dialog has been shown and hidden from
          within an other modal dialog, the latter dialog can't be
          hidden anymore. Calling Dialog.hide() or Dialog.setVisible(false)
          has no effect. Although the dialog remains visible,
          Dialog.isVisible() return false. I've included an example
          source, listed below.
      --8<-----------------------------------------------------------------------
      /*
       * JDK11DialogBug.java
       *
       * Copyright (C) 1997 Raymond Penners
       *
       * Time-stamp: <97/01/12 21:28:59 raymondp>
       */

      /* java version "JDK1.1P" on Windows'95:

         Run it, press "test". Then press "new" in the dialog. In the new
         dialog, press "dismiss". Then press dismiss again. The dialog
         refuses to go away. It's still visible, although isVisible ()
         returns false. There is _no_ way to get rid of the dialog. */
        

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

      class MyDialog extends Dialog implements ActionListener
      {
        Frame frame;
       
        public MyDialog (Frame f)
        {
          super (f, "foobar", true);
          setSize (200, 200);
          frame = f;
          setLayout (new BorderLayout ());

          Panel p = new Panel ();
          p.setLayout (new FlowLayout (FlowLayout.CENTER));
          Button okButton;
          p.add (okButton = new Button ("dismiss"));
          okButton.addActionListener (this);
          Button newButton;
          p.add (newButton = new Button ("new"));
          newButton.addActionListener (this);
          add ("South", p);
        }

        public void actionPerformed (ActionEvent e)
        {
          String s = e.getActionCommand ();
          if (s.equals ("dismiss"))
            hide ();
          else if (s.equals ("new"))
            {
          MyDialog d = new MyDialog (frame);
          System.out.println ("new: open");
          d.setVisible (true);
          System.out.println ("new: closed");
            }
        }
      }


      class MyFrame extends Frame implements ActionListener
      {
        public MyFrame ()
        {
          super ();
          setSize (600,400);
          setTitle ("STR_FRAME_TITLE");


          setLayout (new BorderLayout ());

          Panel toolbar = new Panel ();
          toolbar.setLayout (new FlowLayout (FlowLayout.LEFT));
          Button testButton = new Button ("test");
          testButton.addActionListener (this);
          Button quitButton = new Button ("quit");
          quitButton.addActionListener (this);
          toolbar.add (testButton);
          toolbar.add (quitButton);
          add ("North", toolbar);

        }



        public void actionPerformed (ActionEvent e)
        {
          String s = e.getActionCommand ();
          if (s.equals ("test"))
            {
          System.out.println ("Begin test");
          MyDialog d = new MyDialog (this);
          d.setVisible (true);
          System.out.println ("End test");
            }
          else if (s.equals ("quit"))
            System.exit (0);
        }


      }


      class JDK11DialogBug
      {
        public static void main (String args[])
        {
          MyFrame frame = new MyFrame ();
          frame.setVisible (true);
        }
      }
      --8<-----------------------------------------------------------------------

      ###@###.###

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

            Unassigned Unassigned
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: