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

REGRESSION: Mouse events are disabled in JOptionPane.showConfirmDialog()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • client-libs
    • sparc
    • solaris_2.5.1

      Name: ks84122 Date: 09/27/2004


      Run the Below program & select Exit from the File Menu.
         Try to click on the "Yes" button. Nothing will happen.
         All mouse events are disabled. But If you use tab/return,
         it works .

         This testcase works fine with jdk 1.4.2.
         Also this testcase works fine in Windows & Linux .
         Fails only in Solaris.


      TestCase :

      import javax.swing.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.*;
      import javax.swing.event.*;
      import java.awt.event.*;
      import javax.swing.UIManager;


      public class Test extends JFrame
                      implements ActionListener{

          JMenuBar JMenuBar1 = new JMenuBar();
          DMenu fileMenu = new DMenu ("File");
          JMenuItem openItem = new JMenuItem();
          JSeparator JSeparator1 = new JSeparator();
          JMenuItem exitItem = new JMenuItem();

          JMenuBar menuBar = new JMenuBar();
          JMenu menu = new JMenu("File 1");
          JMenuItem menuItem = new JMenuItem();


        Test(){

          // File 1 Menu
           menuItem.setText("Exit");
           menuItem.addActionListener(this);
           menu.add(menuItem);
           menuBar.add(menu);

         // File Menu
           openItem.setText("Open");
           exitItem.setText("Exit");
           exitItem.addActionListener(this);
           menuBar.add(fileMenu);
           setJMenuBar(menuBar);

           pack();
           setVisible(true);

        }
      public void actionPerformed(ActionEvent e) {
              try {
                  Toolkit.getDefaultToolkit().beep();
                  int reply = JOptionPane.showConfirmDialog(this,
                                                            "Do you really want to exit?",
                                                            "Exit" ,
                                                            JOptionPane.YES_NO_OPTION,
                                                            JOptionPane.QUESTION_MESSAGE);
                  if (reply == JOptionPane.YES_OPTION) {
                      this.setVisible(false);
                      this.dispose();
                      System.exit(0);
                  }
              } catch (Exception ex) {
              }
         }


         public static void main(String[] argv){
         try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
                  e.printStackTrace();
             }
              Test test = new Test();
              test.show();
         }

        private void buildMenu() {
              fileMenu.add(openItem);
              fileMenu.add(JSeparator1);
              fileMenu.add(exitItem);
          }


      //To add menu items during runtime.
        private final class DMenu extends JMenu {
              private String myMenu;

              public DMenu (String s) {
                  super (s);
                  myMenu = s;
              }

              public void setPopupMenuVisible (boolean b) {

                  buildMenu();
                  super.setPopupMenuVisible(b);
              }
          }

      }
      _____________________________________________

      Release Regression From :
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 311324)
      ======================================================================

            kbalasubsunw Kannan Balasubramanian (Inactive)
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: