當前位置: 首頁>>代碼示例>>Java>>正文


Java StageStyle.UTILITY屬性代碼示例

本文整理匯總了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());
    }
 
開發者ID:mhusam,項目名稱:ChessBot,代碼行數:28,代碼來源:UIUtils.java

示例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);
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:42,代碼來源:Gui.java


注:本文中的javafx.stage.StageStyle.UTILITY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。