-
Bug
-
Resolution: Unresolved
-
P5
-
None
-
5.0
-
Cause Known
-
x86
-
windows_xp
javadoc specification for MouseListener.mouseReleased() method tells:
Invoked when a mouse button has been released on a component.
But in fact mouseReleased callback method is invoked on the component where the mouse button was pressed. You can reproduce it running following test program:
===
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.*;
public class Test extends Frame {
public Test() throws HeadlessException {
setLayout(new FlowLayout());
add(new Pane());
add(new Pane());
setSize(200, 200);
setVisible(true);
}
public static void main(String[] args) {
new Test();
}
public static class Pane extends Panel {
private static int i = 0;
private String name;
public Pane() {
name = "Panel " + ++i;
setBackground(Color.blue);
setPreferredSize(new Dimension(20, 20));
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
System.out.println("pressed: " + name);
}
public void mouseReleased(MouseEvent e) {
System.out.println("released: " + name);
}
});
}
}
}
===
Launch the program and move the mouse on first blue panel (left), press first (left by default) mouse button,
drag the mouse on second blue panel (right) and release mouse button. You sees on the console:
pressed: Panel 1
released: Panel 1
But according to the spec it should be:
pressed: Panel 1
released: Panel 2
###@###.### 2005-04-14 12:00:19 GMT
Invoked when a mouse button has been released on a component.
But in fact mouseReleased callback method is invoked on the component where the mouse button was pressed. You can reproduce it running following test program:
===
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.*;
public class Test extends Frame {
public Test() throws HeadlessException {
setLayout(new FlowLayout());
add(new Pane());
add(new Pane());
setSize(200, 200);
setVisible(true);
}
public static void main(String[] args) {
new Test();
}
public static class Pane extends Panel {
private static int i = 0;
private String name;
public Pane() {
name = "Panel " + ++i;
setBackground(Color.blue);
setPreferredSize(new Dimension(20, 20));
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
System.out.println("pressed: " + name);
}
public void mouseReleased(MouseEvent e) {
System.out.println("released: " + name);
}
});
}
}
}
===
Launch the program and move the mouse on first blue panel (left), press first (left by default) mouse button,
drag the mouse on second blue panel (right) and release mouse button. You sees on the console:
pressed: Panel 1
released: Panel 1
But according to the spec it should be:
pressed: Panel 1
released: Panel 2
###@###.### 2005-04-14 12:00:19 GMT