本文整理汇总了Java中javafx.stage.StageStyle.UTILITY属性的典型用法代码示例。如果您正苦于以下问题:Java StageStyle.UTILITY属性的具体用法?Java StageStyle.UTILITY怎么用?Java StageStyle.UTILITY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javafx.stage.StageStyle
的用法示例。
在下文中一共展示了StageStyle.UTILITY属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alwaysInTop
public static void alwaysInTop(Alert alert) {
try{
DialogPane root = alert.getDialogPane();
Stage dialogStage = new Stage(StageStyle.UTILITY);
for (ButtonType buttonType : root.getButtonTypes()) {
ButtonBase button = (ButtonBase) root.lookupButton(buttonType);
button.setOnAction(evt -> {
root.setUserData(buttonType);
dialogStage.close();
});
}
root.getScene().setRoot(new Group());
Scene scene = new Scene(root);
dialogStage.setScene(scene);
dialogStage.initModality(Modality.APPLICATION_MODAL);
dialogStage.setAlwaysOnTop(true);
dialogStage.setResizable(false);
dialogStage.showAndWait();
}catch(Exception e){
}
// Optional<ButtonType> result = Optional.ofNullable((ButtonType) root.getUserData());
}
示例2: runProgressTask
public void runProgressTask(String labelText, Consumer<DoubleConsumer> task, Runnable onSuccess, Consumer<Throwable> onError) {
Stage stage = new Stage(StageStyle.UTILITY);
stage.initOwner(this.scene.getWindow());
VBox pane = new VBox(GuiConstants.padding);
stage.setScene(new Scene(pane));
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOnCloseRequest(event -> event.consume());
stage.setResizable(false);
stage.setTitle("Operation progress");
pane.setPadding(new Insets(GuiConstants.padding));
pane.getChildren().add(new Label(labelText));
ProgressBar progress = new ProgressBar(0);
progress.setPrefWidth(400);
pane.getChildren().add(progress);
stage.show();
Task<Void> jfxTask = new Task<Void>() {
@Override
protected Void call() throws Exception {
task.accept(cProgress -> Platform.runLater(() -> progress.setProgress(cProgress)));
return null;
}
};
jfxTask.setOnSucceeded(event -> {
onSuccess.run();
stage.hide();
});
jfxTask.setOnFailed(event -> {
onError.accept(jfxTask.getException());
stage.hide();
});
threadPool.execute(jfxTask);
}