[vtkusers] Java AddObserver and Events!
Jeff Lee
jeff at cdnorthamerica.com
Fri Jan 13 16:21:22 EST 2006
private DelayAction _delayAction = new DelayAction();
private Timer timer = new Timer(10, _delayAction);
iren.AddObserver("CreateTimerEvent", this, "StartTimer");
...
public void StartTimer() {
if (timer.isRunning())
timer.stop();
timer.setRepeats(false);
timer.start();
}
private class DelayAction implements ActionListener {
public void actionPerformed(ActionEvent evt) {
Lock();
iren.TimerEvent();
UnLock();
}
}
This was all done inside of vtkCanvas. Have a look there.
Regards,
Jeff
Chris Hughes wrote:
>Hi VTKUsers!
>
>I have been struggling to work out how to use the AddObserver to add events
>to the Interactor in Java. Could anyone please give me an example of how to
>get to work the TimerEvent and the KeyPressEvent?
>
>I have so far managed to get it to work for StartEvent, but I need to be
>able to write two functions. One which gets called every 25th of a second,
>but I do not know how to set the timer. And the second which gets called on
>a keyPress and changes different variables based on which key was pressed,
>so I need to be able to read which key was pressed!
>
>Many Thanks,
>
>Chris
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
More information about the vtkusers
mailing list