-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
None
-
beta
-
generic
-
generic
-
Verified
Name: ssR10077 Date: 07/05/2000
On following example MyButton doesn't get first MOUSE_PRESSED after
MOUSE_MOVED and gets MOUSE_ENTERED/MOUSE_EXITED on every press or
release of mouse button.
import java.awt.*;
import java.awt.event.*;
public class MouseTest extends Frame {
public static void main(String argv[]) {
MouseTest test = new MouseTest();
test.setVisible(true);
}
MouseTest() {
super("MouseTest");
Container c = new LWContainer();
Component b = new MyButton();
c.add(b);
add(c);
setSize(200,200);
}
}
class LWContainer extends Container implements MouseMotionListener {
LWContainer() {
addMouseMotionListener(this);
}
public void mouseMoved(MouseEvent e) {
System.out.println("Mouse Moved");
}
public void mouseDragged(MouseEvent e) {
System.out.println("Mouse Dragged");
}
}
class MyButton extends Component implements MouseListener {
MyButton() {
setSize(50,30);
setBackground(Color.red);
addMouseListener(this);
}
public void paint(Graphics g) {
Dimension d = getSize();
g.clearRect(0, 0, d.width - 1, d.height -1);
}
public void mousePressed(MouseEvent me) {
System.out.println("Mouse Pressed");
}
public void mouseReleased(MouseEvent me) {
System.out.println("Mouse Released");
}
public void mouseExited(MouseEvent me) {
System.out.println("Mouse Exited");
}
public void mouseEntered(MouseEvent me) {
System.out.println("Mouse Entered");
}
public void mouseClicked(MouseEvent me) {
System.out.println("Mouse Clicked");
}
}
======================================================================
- relates to
-
JDK-4476083 Disabled Components do not receive MouseEvent
-
- Resolved
-