Skip to content

Commit 4451166

Browse files
committed
implement new util for ui timer action
1 parent ee4196c commit 4451166

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/main/java/gr/sqlbrowserfx/utils/JavaFXUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.fxmisc.wellbehaved.event.InputMap;
77
import org.fxmisc.wellbehaved.event.Nodes;
88

9+
import javafx.animation.PauseTransition;
910
import javafx.application.Platform;
1011
import javafx.event.Event;
1112
import javafx.scene.Node;
@@ -15,6 +16,7 @@
1516
import javafx.scene.input.KeyCode;
1617
import javafx.scene.input.KeyCombination;
1718
import javafx.scene.input.ScrollEvent;
19+
import javafx.util.Duration;
1820

1921
public class JavaFXUtils {
2022

@@ -110,5 +112,11 @@ public static void setChildrenDisabled(Node node, boolean disable) {
110112
node.setDisable(disable);
111113
}
112114
}
115+
116+
public static void setTimeout(Runnable runnable, Integer secs) {
117+
var pause = new PauseTransition(Duration.seconds(secs));
118+
pause.setOnFinished(event -> runnable.run());
119+
pause.play();
120+
}
113121

114122
}

0 commit comments

Comments
 (0)