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

modal dialogs don't properly block input to all windows on Solaris/1.2

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.1.8
    • 1.1, 1.1.4, 1.1.5, 1.1.6, 1.2.0
    • client-libs
    • 1.1.8
    • generic, x86, sparc
    • solaris_2.5.1, solaris_2.6, windows_95


        The following application displays a JDialog that is created by the
        following constructor:
          new JDialog(new JFrame(), "Modal Dialog", true)

        The dialog created by this application is modal on Windows NT, but not
        on Solaris.
        =========================================================================
        /*
         * ModalDialogTest.java
         * JDialog created with modality parameter set to true is not modal on
         * Solaris
         *
         */

        import java.awt.BorderLayout;
        import java.awt.Color;
        import java.awt.GridLayout;
        import java.awt.event.*;
        import java.awt.swing.*;

        public class ModalDialogTest extends JPanel implements ActionListener {
           JDialog dialog = new JDialog(new JFrame(), "Modal Dialog", true);

           public static void main( String[] argv ) {
             new ModalDialogTest();
           }

           public ModalDialogTest() {
              JFrame frame = new JFrame("Modal Dialog Test");
              JPanel controlPanel = new JPanel();
              JPanel infoPanel = new JPanel();
              JButton showButton = new JButton("Show Modal Dialog");
              JButton testButton = new JButton("Test");

              frame.getContentPane().setLayout(new BorderLayout());
              infoPanel.setLayout(new GridLayout(0,1));
              showButton.setOpaque(true);
              showButton.setBackground(Color.yellow);
              testButton.setOpaque(true);
              testButton.setBackground(Color.pink);
              controlPanel.add(showButton);
              controlPanel.add(testButton);
              infoPanel.add(new JLabel("Click the \"Show Modal Dialog\" button to display a modal JDialog."));
              infoPanel.add(new JLabel("Click the \"Test\" button to verify dialog modality."));
              frame.getContentPane().add(BorderLayout.NORTH, controlPanel);
              frame.getContentPane().add(BorderLayout.SOUTH, infoPanel);
              dialog.setSize(200,200);

              showButton.addActionListener(this);
              testButton.addActionListener(this);

              frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {System.exit(0);}
                public void windowClosed(WindowEvent e) {System.exit(0);}
              });

              frame.pack();
              frame.setSize(450, 120);
              frame.setVisible(true);
           }

           public void actionPerformed(ActionEvent evt) {
             String command = evt.getActionCommand();

             if (command == "Show Modal Dialog") {
               System.out.println("*** Invoking JDialog.show() ***");
               dialog.setLocation(200,200);
               dialog.show();
             }
             else if (command == "Test") {
               System.out.println("*** Test ***");
             }
           }

        }
        =========================================================================

              xdengsunw Xianfa Deng (Inactive)
              gaurisha Gauri Sharma (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: