|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
Name: yyT116575 Date: 02/08/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
When you add a tooltip to a JLabel, you no longer can listen for MouseMotion
events in any Container behind that JLabel. For example, I added a JLabel to
the JFrame and added a MouseMotionListener to the JFrame. The JFrame sees the
MouseMotion events even when you move across the label. The minute you add a
tooltip to the JLabel, the MouseMotion events are not propogated to the JFrame.
The bug report #4234237 incorrectly closed this as not reproducible. Their
code added the listener to the label, not the JFrame or JPanel.
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MyFrame extends JFrame {
public MyFrame() {
JLabel l1 = new JLabel("This is my label");
/* comment out following line, then MouseEvent will be triggered
* but not tooltip shows up.
*/
l1.setToolTipText("tooltip1");
this.addMouseMotionListener(new MouseMotionListener(){
public void mouseDragged(MouseEvent e){
System.out.println("Dragged " + e.getX() + " " + e.getY());
}
public void mouseMoved(MouseEvent e){
System.out.println("Moved " + e.getX() + " " + e.getY());
}
});
getContentPane().add(l1, BorderLayout.SOUTH);
setSize(200,200);
setVisible(true);
}
public static void main(String args[]){
MyFrame m = new MyFrame();
}
}
(Review ID: 116608)
======================================================================
|