JDK-4165662 : mouseClicked event falling through from JMenu to underlying JPanel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: generic
  • Submitted: 1998-08-11
  • Updated: 1998-08-18
  • Resolved: 1998-08-18
Related Reports
Duplicate :  
Description
The following program shows that mouse events are still falling through
from Swing menus to the underlying components:

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

/** 
 * This demo shows events from a JMenu / JMenuItem falling through to
 * a JPanel.
 *
 * @author Todd C. Parnell, ###@###.###
 */
public class Test extends JFrame {

  public static void main(String[] args) {
    Test t = new Test();
  }

  public Test() {
    super("JMenu / JPanel event test");

    JMenuBar menubar = new JMenuBar();
    this.setJMenuBar(menubar);
    JMenu menu = new JMenu("File");
    menubar.add(menu);

    JMenuItem menuitem = new JMenuItem("test");
    menuitem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
	System.out.println("got menu click");
      }
    });
    menu.add(menuitem);

    JPanel jp = new JPanel();
    jp.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
	System.out.println("jpanel got click");
      }
    });

    this.getContentPane().add(jp);
    this.setSize(100, 100);
    this.show();
  }
}


Comments
PUBLIC COMMENTS mouseClicked event falling through from JMenu to underlying JPanel.
10-06-2004