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

Win32: hide() does not work on modal dialog

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.5.1, windows_nt
    • Verification:
      Not verified

      Description

      Calling the hide() method without calling the dispose() method won't hide the modal dialog box.

      Try click on the "test" button from the testing frame, a testing modal dialog box will be prompted. Click on the "dismiss" will call the hide() method which does not always hide the modal dialog. (we might hvae to click on "test" then "dismiss" several times to proproduce it)

      //
      //-------------------
      import java.awt.*;
      import java.awt.event.*;

      class MyDialog extends Dialog
      {
        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"));
          Button newButton;
          p.add (newButton = new Button ("dismiss-with-dispose"));
          add ("South", p);
          pack();
        }

          public boolean action(Event e, Object arg){
              if (arg instanceof String) {
                  String cmd = (String)arg;
          
                  if(cmd.equals("dismiss")){
                          System.out.println(" Calling hide()");
                          hide();
                          //dispose();
                          return true;
                  } else if (cmd.equals("dismiss-with-dispose")) {
                          System.out.println(" Calling hide() + dispose()");
                          hide();
                          dispose();
                          return true;
                  }
              }
              return false;
          }
          

      }


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

          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 ModalTest
      {
        public static void main (String args[])
        {
          MyFrame frame = new MyFrame ();
          frame.show();
        }
      }

        Attachments

          Activity

            People

            Assignee:
            tballsunw Tom Ball (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: