Name: sgC58550 Date: 05/07/97
When the mouse is pressed and dragged inside of a java.awt.List and if the mouse is quickly dragged
out of the List, the List will stop receiving drag events. Run the code below and press the mouse button
and quickly drag it out of the List.
Buck Hodges.
###@###.###
import java.awt.*;
import java.awt.event.*;
// This test demonstrates how the List doesn't continue getting drag events
// after the mouse has exited the List. List2 below always prints the
// event when it gets a mouse motion event. Click and drag in the List and
// then exit. If you exit quickly (drag the mouse quickly), the List will stop
// getting the drag events.
class List2 extends List {
public List2(int n) {
super(n);
enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
}
public void processMouseMotionEvent(MouseEvent e) {
System.out.println(e);
super.processMouseMotionEvent(e);
}
}
public class ListTest extends Frame {
public ListTest(String s) {
super(s);
}
public static void main(String args[]) {
ListTest f = new ListTest("List Test");
f.setLayout(null);
f.show();
f.setSize(200, 200);
List2 l = new List2(4);
l.addItem("fasdf");
l.addItem("fasdf");
l.addItem("fasdf");
l.addItem("fasdf");
l.addItem("fasdf");
f.add(l);
l.setBounds(20, 20, 100, 100);
f.setBackground(Color.lightGray);
f.pack();
}
}
company - SAS Institute Inc.
======================================================================