JDK-4128125 : Can't properly handle event listeners on compound components
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.5,1.1.6,1.2.0,1.2.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 1998-04-11
  • Updated: 1999-07-01
  • Resolved: 1999-07-01
Related Reports
Duplicate :  
Description
I changed the summary of this bug to reflect the real problem.  The real problem is that compound components can't have listeners attached to them in a meaningful way.  If someone attaches a mouseListener to a JComboBox, they won't receive any events when the user clicks in the arrow button.  This is confusing a number of developers who expect the component to act as a single component, not a collection of smaller ones.
tom.santos@eng 1998-04-13
============

Name: rk38400			Date: 04/11/98
I need to add a mouselistener to a JComboBox in order to
pop up a menu when e.isPopupTrigger().  This works for 
Windows and Motif L&F but when Metal L&F is loaded, no
mouse events are received.
(Review ID: 26387)
======================================================================


//------------------------Move.java------------------------
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;

public class Move
{
    int moveCount = 0;
    int dragCount = 0;

    public static void main(String[] args)
    {
        new Move();
    }
    public Move()
    {
        String[] teams = {"Maple Leafs", "Devils", "Canucks", 
                "Red Wings", "Rangers", "Avalanche"};
        JComboBox combo = new JComboBox(teams);
        JFrame f = new JFrame("Test MouseMotionListener");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        MouseMotionListener mListener = new MouseMotionListener(){
            public void mouseDragged(MouseEvent e) {
                System.out.println("Mouse Dragged " + (dragCount++));
            }
            public void mouseMoved(MouseEvent e) {
                System.out.println("Mouse Moved " + (moveCount++));
            }
        };
        combo.addMouseMotionListener(mListener);
        f.getContentPane().setLayout(new GridLayout(2,1));
        Button b1 = new Button("Some Button");
        b1.addMouseMotionListener(mListener);
        f.getContentPane().add(b1);
        f.getContentPane().add(combo);
        f.setSize(500,300);
        f.show();
    }
}

Comments
WORK AROUND Name: rk38400 Date: 04/11/98 Don't use Metal L&F <g> ======================================================================
11-06-2004

EVALUATION This is a bug because the developers expect to be able to attach a listener to a component and have the listener get called when a sub component gets the event. tom.santos@eng 1998-04-13 This is a duplicate of a more recent bug, '4144505 Compound components don't behave properly'. I'm going to close this one as a duplicate of the newer bug because the newer bug has a more comprehensive laundry list of the problems that compound components (principally JComboBox) have caused. hans.muller@Eng 1999-07-01
01-07-1999