本文整理匯總了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);
}