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)
======================================================================