I have a very simple application in JavaFX: full screen stage with one exit button. Problem is that from time to time (no idea why not always) after clicking on "Exit" button my application blinks (seems that is minimized and maximized in miliseconds). Any ideas?
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.util.Optional;
public class FullScreenExample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Button button = new Button("Exit");
button.setOnAction(event -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.initOwner(stage);
alert.initStyle(StageStyle.UNDECORATED);
alert.initModality(Modality.WINDOW_MODAL);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
Platform.exit();
}
});
VBox box = new VBox();
box.getChildren().add(button);
final Scene scene = new Scene(box);
scene.setFill(null);
stage.setScene(scene);
stage.setFullScreenExitHint("");
stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
stage.setFullScreen(true);
stage.show();
}
}