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

JOptionPane.showInternalMessageDialog() does not create a modal dialog

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 4.1, bdk_1.0, 1.1, 1.1.6, 1.2.0, 1.3.0, 1.3.1
    • client-libs
    • b28
    • generic, x86, sparc
    • generic, solaris_2.5.1, solaris_2.6, windows_95, windows_nt



      Name: rk38400 Date: 05/18/98


      Using the code given below, bring up the internal
      message dialog. Click on the JTextField & focus is
      moved there. Worse if you bring up the
      JOptionPane.showMessageDialog() before dismissing
      the internal dialog you are totally locked up.

      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;

      class TestFrame extends JFrame {
        TestFrame() {
          getContentPane().setLayout(new FlowLayout());

          JButton dlgErrBtn = new JButton("Dialog error msg");
          dlgErrBtn.addActionListener(new DlgErrBtnController());
          getContentPane().add(dlgErrBtn);

          getContentPane().add(new JTextField("hello world"));

          JButton dlgInErrBtn = new JButton("Internal Dialog error msg");
          dlgInErrBtn.addActionListener(new DlgInErrBtnController());
          getContentPane().add(dlgInErrBtn);
          
          addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              System.exit(0);
            }
          });
          
          Msg.setParent(this);
        }

        class DlgErrBtnController extends AbstractAction {
          public void actionPerformed(ActionEvent evt) {
            Msg.err("Hello World\nWe have bugs\n");
          }
        }

        class DlgInErrBtnController extends AbstractAction {
          public void actionPerformed(ActionEvent evt) {
            Msg.errIn("Hello World\nWe have bugs\n");
          }
        }
      }

      class Msg {
        public static void err(String s) {
          if (frame == null)
            System.out.println(s);
          else
            JOptionPane.showMessageDialog(frame.getContentPane(),s,"Standard Dialog",JOptionPane.INFORMATION_MESSAGE);
        }
        public static void errIn(String s) {
          if (frame == null)
            System.out.println(s);
          else
            JOptionPane.showInternalMessageDialog(frame.getContentPane(),s,"Internal Message Dialog",JOptionPane.INFORMATION_MESSAGE);
        }
        
        public static void setParent(JFrame f) {
          frame = f;
        }
        private static JFrame frame;
      }

      public class TestApp {
        TestApp() throws Exception {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          frame = new TestFrame();
          frame.setSize(400,300);
          frame.setVisible(true);
        }

        public static void main(String[] argv) {
          try {
             new TestApp();
          }
          catch(Exception e) {
            System.out.println(e);
            e.printStackTrace();
          }
        }

        TestFrame frame;
      }
      (Review ID: 30613)
      ======================================================================

            joutwatesunw Joshua Outwater (Inactive)
            rkarsunw Ralph Kar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: