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

Modal Dialog Don't receive events

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.6
    • client-libs
    • generic
    • windows_nt



      Name: eyC74480 Date: 06/02/98


      /*
      A basic extension of the java.awt.Dialog class
       */

      import java.awt.*;

      public class InputDialog extends Dialog
      {
      public InputDialog(Frame parent, boolean modal)
      {

      // THIS CAUSES THE DIALOG TO NO LONGER RECEIVE MESSAGES PROPERLY
      super(parent, true);

      // THIS WORKS FINE
      // super(parent, false);

      // This code is automatically generated by Visual Cafe when you add
      // components to the visual environment. It instantiates and initializes
      // the components. To modify the code, only use code syntax that matches
      // what Visual Cafe can generate, or Visual Cafe may be unable to back
      // parse your Java file into its visual environment.
      //{{INIT_CONTROLS
      setLayout(null);
      setSize(insets().left + insets().right + 430,insets().top + insets().bottom + 270);
      textField1 = new java.awt.TextField();
      textField1.setBounds(insets().left + 81,insets().top + 87,111,27);
      add(textField1);
      button1 = new java.awt.Button();
      button1.setLabel("button");
      button1.setBounds(insets().left + 213,insets().top + 165,81,48);
      button1.setBackground(new Color(12632256));
      add(button1);
      setTitle("Input Dialog");
      //}}

      //{{REGISTER_LISTENERS
      SymWindow aSymWindow = new SymWindow();
      this.addWindowListener(aSymWindow);
      SymAction lSymAction = new SymAction();
      button1.addActionListener(lSymAction);
      //}}
      }

      public void addNotify()
      {
         // Record the size of the window prior to calling parents addNotify.
      Dimension d = getSize();

      super.addNotify();

      if (fComponentsAdjusted)
      return;

      // Adjust components according to the insets
      setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
      Component components[] = getComponents();
      for (int i = 0; i < components.length; i++)
      {
      Point p = components[i].getLocation();
      p.translate(insets().left, insets().top);
      components[i].setLocation(p);
      }
      fComponentsAdjusted = true;
      }

          // Used for addNotify check.
      boolean fComponentsAdjusted = false;


      public InputDialog(Frame parent, String title, boolean modal)
      {
      this(parent, modal);
      setTitle(title);
      }

      public synchronized void show()
      {
      Rectangle bounds = getParent().bounds();
      Rectangle abounds = bounds();

      move(bounds.x + (bounds.width - abounds.width)/ 2,
      bounds.y + (bounds.height - abounds.height)/2);

      super.show();
      }

      //{{DECLARE_CONTROLS
      java.awt.TextField textField1;
      java.awt.Button button1;
      //}}

      class SymWindow extends java.awt.event.WindowAdapter
      {
      public void windowClosing(java.awt.event.WindowEvent event)
      {
      Object object = event.getSource();
      if (object == InputDialog.this)
      Dialog1_WindowClosing(event);
      }
      }

      void Dialog1_WindowClosing(java.awt.event.WindowEvent event)
      {
      hide();
      }

      class SymAction implements java.awt.event.ActionListener
      {
      public void actionPerformed(java.awt.event.ActionEvent event)
      {
      Object object = event.getSource();
      if (object == button1)
      button1_Action(event);
      }
      }

      void button1_Action(java.awt.event.ActionEvent event)
      {
      // to do: code goes here.
      setVisible(false);

      }
      }
      (Review ID: 29877)
      ======================================================================

            rkhansunw Robi Khan (Inactive)
            eyusunw Ellis Yu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: