Example usage for javafx.concurrent Service stateProperty

List of usage examples for javafx.concurrent Service stateProperty

Introduction

In this page you can find the example usage for javafx.concurrent Service stateProperty.

Prototype

@Override
    public final ReadOnlyObjectProperty<State> stateProperty() 

Source Link

Usage

From source file:mesclasses.objects.LoadWindow.java

private void temporize(long millis) {
    Service<Object> service = new Service() {
        @Override/* w w w  . j a v  a2  s .  c o  m*/
        protected Task createTask() {
            return new WaitTask(millis);
        }
    };
    service.stateProperty().addListener(
            (ObservableValue<? extends Worker.State> o, Worker.State oldValue, Worker.State newValue) -> {
                switch (newValue) {
                case FAILED:
                case CANCELLED:
                    successful = false;
                    dialogStage.close();
                    break;

                case SUCCEEDED:
                    next();
                }
            });
    service.start();
}