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

Non Modal Dialog cannot be moved in background

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • x86
    • windows_nt



      Name: yyT116575 Date: 03/23/2001


      java version "1.3.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
      Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)

      1. Start up NonModalProblem.main, e.g.

        D:\jdk1.3.1Beta\bin\java -cp . NonModalProblem

      A frame appears with a button to pop up a non modal dialog.
      On my PC the non modal dialog does not move to the backgound
      if the main frame is selected. However on a Sparc machine
      (OS: Solaris 2.6, jdk1.3.0) the dialog does move to the background.

      2. Source:

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      class NonModalProblem implements ActionListener {

        NonModalDialog dialog;
        int number;

        NonModalProblem(JFrame frame) {
          dialog = new NonModalDialog(frame);
        }

        public void actionPerformed(ActionEvent e) {
          dialog.setVisible(true);
        }

        public static void main(String[] args) {
          JFrame frame = new JFrame("NonModalProblem");
          frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
          });

          JButton button = new JButton("Dialog");
          button.addActionListener(new NonModalProblem(frame));
          button.setAlignmentX(Component.CENTER_ALIGNMENT);
          button.setToolTipText("Show dialog");

          Box box = Box.createVerticalBox();
          box.add(Box.createRigidArea(new Dimension (240, 40)));
          box.add(button);
          box.add(Box.createVerticalStrut(40));

          frame.getContentPane().add(box);
          frame.pack();
          frame.setVisible(true);
        }

        class NonModalDialog extends JDialog implements ActionListener {
          JTextField textField1;
          JTextField textField2;

          NonModalDialog(JFrame frame) {
            super(frame, "Non Modal Dialog", false);
            Box box = Box.createVerticalBox();

            box.add(Box.createRigidArea(new Dimension (240, 40)));

            JButton button = new JButton("OK");
            button.addActionListener(this);
            button.setAlignmentX(Component.CENTER_ALIGNMENT);
            box.add(button);
            box.add(Box.createVerticalStrut(20));
            setContentPane(box);
            pack();
          }

          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        }
      }

      (Review ID: 118476)
      ======================================================================

            son Oleg Sukhodolsky (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: