Name: mc57594 Date: 01/29/97
MouseDrag events are not being delivered if the mouse moves
outside the bounding window and should do so (otherwise how can one do
drag and drop?). Compile the following 2 classes, run, and start a drag
within the pink label. Then continue the drag until it moves outside of
the label's bounds. You will see in the console window that the drag
event stop comming once the boundary is crossed. This is not correct,
the events should continue to arrive (with location relative the
component where the drag began) until a mouse release event occurs
regardless of mouse position.
>>>>> class one
import java.awt.*;
public class test extends Frame
{
public test()
{
setLayout(null);
setSize(400, 500);
MyLabel mylabel = new MyLabel();
mylabel.setSize(100, 200);
mylabel.setLocation(10, 20);
add(mylabel);
doLayout();
pack();
show();
}
public Dimension getMinimumSize()
{
return(getSize());
}
public Dimension getPreferredSize()
{
return(getMinimumSize());
}
public Dimension getMaximumSize()
{
return(getMinimumSize());
}
public static void main(String[] argv)
{
new test();
}
}
>>>>> class two
import java.awt.*;
import java.awt.event.*;
public class MyLabel extends Label implements MouseMotionListener
{
public MyLabel()
{
super();
setBackground(Color.pink);
setForeground(Color.black);
addMouseMotionListener(this);
}
public Dimension getMinimumSize()
{
return(getSize());
}
public Dimension getPreferredSize()
{
return(getMinimumSize());
}
public Dimension getMaximumSize()
{
return(getMinimumSize());
}
public void mouseDragged(MouseEvent ev)
{
System.out.println("MouseDragged: " + ev);
}
public void mouseMoved(MouseEvent ev)
{
}
}
======================================================================