JDK-4126295 : mouseDown event not working after setting tooltip for JLabel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.5,1.1.7
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1998-04-06
  • Updated: 1999-06-25
  • Resolved: 1999-06-25
Related Reports
Duplicate :  
Description

Name: rk38400			Date: 04/06/98


I have a class that is a subclass of JLabel.
I use this class as a handle for controlling an
external device. The handle is clicked or 
clicked and dragged.

I attempted to add tool tips to these "handles".
I used handle.setToolTipText(String s) to set the
tool tip.
Tool tips started working.
Now I can't click or drag my handles. In fact 
the mouseDown method never gets called in my 
MouseListener subclass.

BTW the mouseEntered method still operates.
(Review ID: 23987)
======================================================================

Attaching tooltips to a swing object can stop mouse events from being delivered to the object.  Source code that demonstrates the problem was submitted as a follow-up to closed bug #4126295 by 'willy8' For convenience, this code is reproduced below.

java version "1.1.7A"
java full version "JDK1.1.7S"
swing version is 1.1.1 beta 1

This program reproduces the bug. Compare clicking on the green panel to the red panel.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JApplet;
import javax.swing.JPanel;
import javax.swing.ToolTipManager;


public class tooltipbug extends JApplet implements MouseListener {
public void init() {
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
panel1.setBackground(Color.green);
panel2.setBackground(Color.red);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
pane.add(panel1, BorderLayout.WEST);
pane.add(panel2, BorderLayout.EAST);
ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); toolTipManager.registerComponent(panel2);
addMouseListener(this);
}

public void mouseClicked(MouseEvent e) {
System.err.println("Woo, an event!");
}
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
}
(Review ID: 57318) 
======================================================================

Comments
WORK AROUND Name: rk38400 Date: 04/06/98 I have had to remove my sorely needed tool tips for now. ======================================================================
11-06-2004

PUBLIC COMMENTS I can not reproduce this problem. To continue to investigate, I'll need the code from the customer. My example based on the problem description is enclosed and works. mouseMoved and mouseDragged event work fine to the JLabel with Tooltips. richard.schiavi@Eng 1998-04-13 import com.sun.java.swing.*; import java.awt.event.*; import java.awt.*; public class Handles extends JPanel { static JFrame frame; public Handles() { JLabel l1 = new JLabel("YO"); JLabel l2 = new JLabel("YO2"); l1.setToolTipText("tooltip1"); l2.setToolTipText("tooltip2"); final JCheckBox b = new JCheckBox("Disable ToolTips"); b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if (b.isSelected()){ ToolTipManager.sharedInstance().setEnabled(true); } else { ToolTipManager.sharedInstance().setEnabled(false); } } }); l1.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ System.out.println("L1: mouseClicked " + e); } }); l1.addMouseMotionListener(new MouseMotionListener(){ public void mouseDragged(MouseEvent e){ System.out.println("L1: dragged"); } public void mouseMoved(MouseEvent e){ System.out.println("L1: moved"); } }); l2.addMouseMotionListener(new MouseMotionListener(){ public void mouseDragged(MouseEvent e){ System.out.println("L2: dragged"); } public void mouseMoved(MouseEvent e){ System.out.println("L2: moved"); } }); l2.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ System.out.println("L2: mouseClicked " + e); } }); add(b); add(l1); add(l2); } public static void main(String args[]){ Handles h = new Handles(); frame = new JFrame("Tooltip Mouse Events"); frame.getContentPane().add("Center", h); frame.pack(); frame.setVisible(true); } }
10-06-2004

EVALUATION I can not reproduce this problem. To continue to investigate, I'll need the code from the customer. My example based on the problem description is enclosed and works mouseMoved and mouseDragged event work fine to the JLabel with Tooltips. richard.schiavi@Eng 1998-04-13 import com.sun.java.swing.*; import java.awt.event.*; import java.awt.*; public class Handles extends JPanel { static JFrame frame; public Handles() { JLabel l1 = new JLabel("YO"); JLabel l2 = new JLabel("YO2"); l1.setToolTipText("tooltip1"); l2.setToolTipText("tooltip2"); final JCheckBox b = new JCheckBox("Disable ToolTips"); b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if (b.isSelected()){ ToolTipManager.sharedInstance().setEnabled(true); } else { ToolTipManager.sharedInstance().setEnabled(false); } } }); l1.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ System.out.println("L1: mouseClicked " + e); } }); l1.addMouseMotionListener(new MouseMotionListener(){ public void mouseDragged(MouseEvent e){ System.out.println("L1: dragged"); } public void mouseMoved(MouseEvent e){ System.out.println("L1: moved"); } }); l2.addMouseMotionListener(new MouseMotionListener(){ public void mouseDragged(MouseEvent e){ System.out.println("L2: dragged"); } public void mouseMoved(MouseEvent e){ System.out.println("L2: moved"); } }); l2.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ System.out.println("L2: mouseClicked " + e); } }); add(b); add(l1); add(l2); } public static void main(String args[]){ Handles h = new Handles(); frame = new JFrame("Tooltip Mouse Events"); frame.getContentPane().add("Center", h); frame.pack(); frame.setVisible(true); } } A test case has been added to the Description. Reopening this bug since it was closed out as not reproducible. sheri.good@Eng 1999-04-30
30-04-1999