如何获得EventDispatcherChain

时间:2013-01-31 19:12:16

标签: javafx-2

我正在尝试创建自定义ActionEvent。当我尝试发送事件时,scene.dipatchEvent正在向我询问EventDispatcherChain对象。我没有做任何复杂的事情来实际创建新EventDispatcherChain的实现。我如何获得默认的EventDispatcherChain,以便将其传递给scene.dispatchEvent

的EventType

public class SquirrelEventType extends EventType<SquirrelActionEvent> {

    public SquirrelEventType() {
        super("Squirrel.NotifyPreloader");
    }

}

事件

public class SquirrelActionEvent extends ActionEvent {

private Preloader.PreloaderNotification preloaderNotification;
private String details;
private double progress;

/**
 *
 */
public SquirrelActionEvent(double progress){
    preloaderNotification = new Preloader.ProgressNotification(progress);
}

public PreloaderNotification getPreloaderNotification() {
    return preloaderNotification;
}

public void setPreloaderNotification(PreloaderNotification preloaderNotification) {
    this.preloaderNotification = preloaderNotification;
}

以下是对dispatchEvent

的致电
SquirrelActionEvent event = new SquirrelActionEvent(0.1d);
mainScene.getEventDispatcher().dispatchEvent(event, null);

1 个答案:

答案 0 :(得分:1)

事件只是通过Event.fireEvent()发送,这是一种静态方法。