JDK-5107737 : REGRESSION: Mouse events are disabled in JOptionPane.showConfirmDialog()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 2004-09-27
  • Updated: 2005-04-08
  • Resolved: 2005-04-08
Related Reports
Duplicate :  
Description
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) 
======================================================================

Comments
EVALUATION Fails only on Solaris - re-assigning to AWT. ###@###.### 2004-09-28 Was unable to reproduce the problem on SuSe with MToolkit. Perhaps this problem is CDE specific??? ###@###.### 2004-10-01 Wasn't able to do it on CDE with direct display and remote both on Solaris 8. Also, not reproducible on Solaris 9 with Gnome. Asking submitter about any specific environment. ###@###.### 10/4/04 13:20 GMT I figured out that the bug is reproducible up to Mustang-b25 on Solaris+CDE. It's not reprodusible since b26. ###@###.### 2005-03-31 12:09:18 GMT If you choose File menu, next Exit, next click No with help of keyboard then if you choose File1 menu after that it begins to behave the same way - JOptionPane doen't react to mouse events. ###@###.### 2005-04-01 08:47:54 GMT I suspect this is not focus issue. ###@###.### 2005-04-01 09:03:52 GMT I am able to reproduce the bug on both CDE and GNOME. Also able to reproduce with both Motif and XToolkit. - Bug not reproduceable on 1.4.2 - Bug reproduceable since 1.5.0 and all the way upto 1.6.0 b25 (as mentioned by anton) ###@###.### 2005-04-04 19:23:24 GMT Most possibly a duplicate of 6196089. ###@###.### 2005-04-05 08:42:19 GMT The fix for 6196089 needs to be backported to 5.0 u4 update release. It's a one line change. ###@###.### 2005-04-06 01:58:13 GMT Please close this as a duplicate of 6196089 and open a SubCR of that bug to backport this. ###@###.### 2005-04-08 14:54:15 GMT
06-04-2005

WORK AROUND Create the menu in the Test constructor. For e.g. insert a call buildMenu() in line# 36 and/or remove buildMenu() from the setPopupMenuVisible() method. JOptionPane works fine with mouse events. ###@###.### 2005-04-04 19:23:25 GMT
04-04-2005