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

JPopupMenu canceled on mouse click without ActionEvent on Mac OS X

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7u51
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_51"
      Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin martinsn-mac1.hob.de 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64


      A DESCRIPTION OF THE PROBLEM :
      A JPopupMenu which is opened from a JWindow is cancelled by Swing when clicking on a JMenuItem inside the JPopupMenu. The JMenuItem does not receive an ActionEvent.

      The problem occurs on Mac OS X only and works fine on Windows and Linux.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start the sample application (see below).
      2. Within the window click on the button "ShowPopup".
      3. Within the popup menu click on "ClickMe".
      4. The ActionListener of button "ClickMe" does not fire.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The ActionListener of button "ClickMe" should fire and the sample application should be closed.

      ACTUAL -
      The popup menu was closed after step 3 and nothing else happened.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package bintools;

      import java.awt.BorderLayout;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JMenuItem;
      import javax.swing.JPopupMenu;
      import javax.swing.JWindow;

      public class c_awttest10 {

      public static void main(String[] args) {
      JFrame ds_f = new JFrame();
      JWindow ds_winfull = new JWindow(ds_f);
      final JButton ds_b1 = new JButton("ShowPopup");
      ds_b1.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
      JPopupMenu ds_p = new JPopupMenu();
      JMenuItem ds_m = new JMenuItem("ClickMe");
      ds_m.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
      System.out.println("#actionPerformed: " + e);
      System.exit(0);
      }
      });
      ds_p.add(ds_m);
      ds_p.show(ds_b1, 0, 0);
      }
      });
      ds_winfull.add(ds_b1, BorderLayout.NORTH);
      JButton ds_b2 = new JButton("Close");
      ds_b2.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
      System.exit(0);
      }

      });
      ds_winfull.add(ds_b2, BorderLayout.SOUTH);
      ds_winfull.setBounds(0, 100, 600, 300);
      ds_winfull.setVisible(true);
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The sample works when the parent window of the popup menu is a "JFrame" instead of a "JWindow".


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dmarkov Dmitry Markov
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: