2
import java.awt.event.*;
3
import org.jcsp.util.*;
4
import org.jcsp.lang.*;
7
public class ActiveContainerExample {
9
public static void main (String argv[]) {
11
final Frame root = new Frame ("ActiveContainer Example");
13
final One2OneChannel mouseEvent = Channel.one2one (new OverWriteOldestBuffer (10));
15
final ActiveContainer container = new ActiveContainer ();
16
container.addMouseEventChannel (mouseEvent.out ());
19
root.setSize (400, 400);
20
root.setVisible (true);
27
boolean running = true;
29
final MouseEvent event = (MouseEvent) mouseEvent.in ().read ();
30
switch (event.getID ()) {
31
case MouseEvent.MOUSE_ENTERED:
32
System.out.println ("MOUSE_ENTERED");
34
case MouseEvent.MOUSE_EXITED:
35
System.out.println ("MOUSE_EXITED");
37
case MouseEvent.MOUSE_PRESSED:
38
System.out.println ("MOUSE_PRESSED");
40
case MouseEvent.MOUSE_RELEASED:
41
System.out.println ("MOUSE_RELEASED");
43
case MouseEvent.MOUSE_CLICKED:
44
if (event.getClickCount() > 1) {
45
System.out.println ("MOUSE_DOUBLE_CLICKED ... goodbye!");
48
System.out.println ("MOUSE_CLICKED ... *double* click to quit!");
53
root.setVisible (false);