[Zest] How to add Listener For GraphNode/GraphConnection? [message #249209] |
Fri, 05 June 2009 01:34  |
Eclipse User |
|
|
|
Hello,
I try to add listener for GraphNode/GraphConnection but it doens't work.
I.e. I want to print something when user double clicks one of the
GraphNodes and GraphConnections:
public class TestListener {
public static void main(String[] args) {
Display d = new Display();
Shell shell = new Shell(d);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);
Graph g = new Graph(shell, SWT.NONE);
GraphNode n = new GraphNode(g, SWT.NONE, "Paper");
GraphNode n2 = new GraphNode(g, SWT.NONE, "Rock");
GraphNode n3 = new GraphNode(g, SWT.NONE, "Scissors");
GraphConnection c1 = new GraphConnection(g, SWT.NONE, n, n2);
GraphConnection c2 = new GraphConnection(g, SWT.NONE, n2, n3);
GraphConnection c3 = new GraphConnection(g, SWT.NONE, n3, n);
n.addListener(SWT.MouseDoubleClick, new Listener() {
public void handleEvent(Event event) {
System.out.println("hello!");
}
});
c1.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event event) {
System.out.println("hi!");
}
});
g.setLayoutAlgorithm(new SpringLayoutAlgorithm(
LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
shell.open();
while (!shell.isDisposed()) {
while (!d.readAndDispatch()) {
d.sleep();
}
}
}
}
Why GraphNode.addListener() doesn't work?
Thanks in advance.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04142 seconds