commit 21/03/2025
This commit is contained in:
@@ -13,6 +13,7 @@ import javafx.stage.StageStyle;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class AutoCloseAlert {
|
||||
|
||||
@@ -43,8 +44,9 @@ public class AutoCloseAlert {
|
||||
* @param header the header of the alert
|
||||
* @param content the content of the alert
|
||||
* @param seconds the number of seconds before the alert is closed, or put 0 to keep it open
|
||||
* @param onClose What to do after auto close
|
||||
*/
|
||||
public static void show(String title, String header, String content, int seconds) {
|
||||
public static void show(String title, String header, String content, int seconds, Consumer<String> onClose) {
|
||||
Platform.runLater(()->{
|
||||
// close previous alert before showing a new one
|
||||
Optional.ofNullable(currentAlertStage).ifPresent(Stage::close);
|
||||
@@ -88,6 +90,7 @@ public class AutoCloseAlert {
|
||||
if (currentAlertStage == alertStage) {
|
||||
currentAlertStage = null;
|
||||
}
|
||||
if (onClose!=null) onClose.accept(shownTitle);
|
||||
clear();
|
||||
} );
|
||||
delay.play();
|
||||
|
||||
Reference in New Issue
Block a user