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


Java Dialog.initOwner方法代碼示例

本文整理匯總了Java中javafx.scene.control.Dialog.initOwner方法的典型用法代碼示例。如果您正苦於以下問題:Java Dialog.initOwner方法的具體用法?Java Dialog.initOwner怎麽用?Java Dialog.initOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.Dialog的用法示例。


在下文中一共展示了Dialog.initOwner方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showAbout

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
public void showAbout(ActionEvent actionEvent) throws URISyntaxException {
    Dialog<Void> dialog = new Dialog<>();
    dialog.setTitle("Tenhou Visualizer について");
    dialog.initOwner(this.root.getScene().getWindow());
    dialog.getDialogPane().getStylesheets().add(this.getClass().getResource(Main.properties.getProperty("css")).toExternalForm());
    dialog.getDialogPane().setGraphic(new ImageView(new Image("/logo.png")));
    dialog.getDialogPane().setHeaderText("TenhouVisualizer v0.3");
    final Hyperlink oss = new Hyperlink("open-source software");
    final URI uri = new URI("https://crazybbb.github.io/tenhou-visualizer/thirdparty");
    oss.setOnAction(e -> {
        try {
            Desktop.getDesktop().browse(uri);
        } catch (IOException e1) {
            throw new UncheckedIOException(e1);
        }
    });
    dialog.getDialogPane().setContent(new TextFlow(new Label("Powered by "), oss));
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    dialog.showAndWait();
}
 
開發者ID:CrazyBBB,項目名稱:tenhou-visualizer,代碼行數:21,代碼來源:AppController.java

示例2: confirmDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
/**
 * Displays a confirmation dialog box.
 *
 * @param node    a node attached to the stage to be used as the owner of the dialog.
 * @param header  the header message for the dialog.
 * @param content the main message for the dialog.
 * @param icon    the icon for the dialog.
 * @param buttons the {@link ButtonType} that should be displayed on the confirmation dialog.
 * @return the {@link ButtonType} corresponding to user's choice.
 */
public static ButtonType confirmDialog(Node node, String header, String content, Node icon, ButtonType... buttons) {
    Dialog<ButtonType> dlg = new Dialog<>();
    dlg.initOwner(Dialogs.getStage(node));
    setAlwaysOnTop(dlg);
    dlg.setTitle("binjr");
    dlg.getDialogPane().setHeaderText(header);
    dlg.getDialogPane().setContentText(content);
    if (icon == null) {
        icon = new Region();
        icon.getStyleClass().addAll("dialog-icon", "help-icon");
    }
    dlg.getDialogPane().setGraphic(icon);
    if (buttons == null || buttons.length == 0) {
        buttons = new ButtonType[]{ButtonType.YES, ButtonType.NO};
    }
    dlg.getDialogPane().getButtonTypes().addAll(buttons);
    return dlg.showAndWait().orElse(ButtonType.CANCEL);
}
 
開發者ID:fthevenet,項目名稱:binjr,代碼行數:29,代碼來源:Dialogs.java

示例3: setupDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
private static void setupDialog(Window owner, String title, String headerText, String contentText, Dialog<?> alert) {
	alert.setTitle(title);
	alert.setHeaderText(headerText);
	alert.setContentText(contentText);
	alert.initOwner(owner);
	alert.initModality(Modality.WINDOW_MODAL);
}
 
開發者ID:enoy19,項目名稱:keyboard-light-composer,代碼行數:8,代碼來源:DialogUtil.java

示例4: show

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
static void show(Window window) {
  try {
    Pair<OptionsController, DialogPane> pair = Util.renderFxml(OptionsController.class);
    Dialog<Void> dialog = new Dialog<>();
    dialog.initOwner(window);
    dialog.setDialogPane(pair.getValue());
    dialog.show();
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:12,代碼來源:OptionsController.java

示例5: showMessageDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
public static void showMessageDialog(Window window, String title, String message) {
  Dialog<ButtonType> dialog = createDialog();
  if (window != null) {
    dialog.initOwner(window);
  }
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
  dialog.setTitle(title);
  dialog.setContentText(message);
  dialog.showAndWait();
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:11,代碼來源:Util.java

示例6: showConfirmDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
public static boolean showConfirmDialog(Window window, String title, String message) {
  Dialog<ButtonType> dialog = createDialog();
  if (window != null) {
    dialog.initOwner(window);
  }
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
  dialog.setTitle(title);
  dialog.setContentText(message);
  return dialog.showAndWait().orElse(ButtonType.CANCEL).equals(ButtonType.OK);
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:11,代碼來源:Util.java

示例7: showConfirmCancelDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
/**
 * 
 * @param window
 * @param title
 * @param message
 * @return {@code ButtonType.YES, ButtonType.NO, ButtonType.CANCEL}
 */
public static ButtonType showConfirmCancelDialog(Window window, String title, String message) {
  Dialog<ButtonType> dialog = createDialog();
  if (window != null) {
    dialog.initOwner(window);
  }
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
  dialog.setTitle(title);
  dialog.setContentText(message);
  return dialog.showAndWait().orElse(ButtonType.CANCEL);
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:18,代碼來源:Util.java

示例8: showYesOrNoDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
public static Optional<Pair<String, String>> showYesOrNoDialog(Stage stage, String title, String message,
		Consumer<? super Pair<String, String>> consumer, Consumer<Dialog<Pair<String, String>>> dialogHandler) {

	// Create the custom dialog.
	Dialog<Pair<String, String>> dialog = new Dialog<>();
	dialog.setTitle(title);
	dialog.setHeaderText(message);

	// Set the button types.
	ButtonType yesBtn = new ButtonType("Yes", ButtonData.YES);
	ButtonType noBtn = new ButtonType("No", ButtonData.NO);

	dialog.getDialogPane().getButtonTypes().addAll(yesBtn, noBtn);

	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == yesBtn) {
			return new Pair<>("RESULT", "Y");
		} else if (dialogButton == noBtn) {
			return new Pair<>("RESULT", "N");
		}
		return null;
	});

	dialog.initOwner(stage);
	if (dialogHandler != null)
		dialogHandler.accept(dialog);

	Optional<Pair<String, String>> result = dialog.showAndWait();

	if (consumer != null)
		result.ifPresent(consumer);

	return result;

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:36,代碼來源:DialogUtil.java

示例9: getProgressDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
public static Dialog getProgressDialog(Window owner, Task task) {
    Dialog dialog = new Dialog();
    dialog.initStyle(StageStyle.UNDECORATED);
    dialog.initOwner(owner);
    ProgressBar progressBar = new ProgressBar();
    progressBar.setPrefSize(300, 30);
    Label progressLabel = new Label();
    progressLabel.setPrefWidth(300);
    progressLabel.setAlignment(Pos.BASELINE_CENTER);
    VBox vBox = new VBox(progressBar, progressLabel);
    vBox.setFillWidth(true);
    vBox.setPadding(new Insets(10, 10, 10, 10));
    dialog.getDialogPane().setContent(vBox);
    progressBar.progressProperty().bind(task.progressProperty());
    progressLabel.textProperty().bind(task.messageProperty());
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    Node closeButton = dialog.getDialogPane().lookupButton(ButtonType.CLOSE);
    closeButton.managedProperty().bind(closeButton.visibleProperty());
    closeButton.setVisible(false);
    EventHandler onSucceeded = task.getOnSucceeded();
    task.setOnSucceeded(event -> {
        dialog.close();
        if (onSucceeded != null) {
            onSucceeded.handle(event);
        }
    });
    return dialog;
}
 
開發者ID:m-krajcovic,項目名稱:photometric-data-retriever,代碼行數:29,代碼來源:FXMLUtils.java

示例10: createDiffDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
public void createDiffDialog(MergeDiffInfo<?> mergeDiff, String title, Window owner) {
    final FactoryDiffWidget factoryDiffWidget = new FactoryDiffWidget(uniformDesign,attributeEditorBuilder);
    factoryDiffWidget.updateMergeDiff(mergeDiff);


    Dialog<Void> dialog = new Dialog<>();
    dialog.initOwner(owner);
    dialog.setTitle(title);
    dialog.setHeaderText(title);

    ButtonType loginButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(loginButtonType/*, ButtonType.CANCEL*/);

    final BorderPane pane = new BorderPane();
    final Node diffWidgetContent = factoryDiffWidget.createContent();

    pane.setCenter(diffWidgetContent);
    pane.setPrefWidth(1000);
    pane.setPrefHeight(750);
    dialog.getDialogPane().setContent(pane);
    dialog.setResizable(true);

    dialog.getDialogPane().getStylesheets().add(getClass().getResource("/de/factoryfx/javafx/css/app.css").toExternalForm());

    if (!mergeDiff.hasNoConflicts()){
        dialog.setTitle("Konflikte");
        dialog.setHeaderText("Konflikte");
        diffWidgetContent.getStyleClass().add("error");
    }



    dialog.showAndWait();
}
 
開發者ID:factoryfx,項目名稱:factoryfx,代碼行數:35,代碼來源:DiffDialogBuilder.java

示例11: onDebug

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
@FXML
public void onDebug(ActionEvent actionEvent) {
    final ObservableMap<String, String> rmbStyleMap = FXCollections.observableHashMap();
    rmbStyleMap.addListener((InvalidationListener)(observable) ->
            rmb.setStyle(rmbStyleMap.entrySet().stream()
                    .map((entry) -> entry.getKey() + ": " + entry.getValue() + ";")
                    .reduce((s1, s2) -> s1 + s2).orElse("")));

    final Button bSize = new Button("Size");
    bSize.setOnAction((event) -> rmbStyleMap.put("-fx-size", "35"));

    final Button bGraphic = new Button("Graphic");
    bGraphic.setOnAction((event) -> rmbStyleMap.put("-fx-graphic","url(\"http://icons.iconarchive.com/icons/hopstarter/button/16/Button-Add-icon.png\")"));

    final HBox menuButtonRow = new HBox();
    menuButtonRow.setAlignment(Pos.CENTER_LEFT);
    menuButtonRow.getChildren().addAll(new Label("RadialMenuButton:"), bSize, bGraphic);

    final VBox vbox = new VBox();
    vbox.getChildren().addAll(menuButtonRow);

    final Dialog dialog = new Dialog();
    dialog.initModality(Modality.NONE);
    dialog.initOwner(pane.getScene().getWindow());
    dialog.setTitle("Debugging actions");
    dialog.setHeaderText("Select an action to perform below:");
    dialog.getDialogPane().setContent(vbox);
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    dialog.show();
}
 
開發者ID:dejv78,項目名稱:j.commons,代碼行數:31,代碼來源:DemoFXMLController.java

示例12: displayDevKeyDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
/**
 * This is for testing purposes, to allow the developer select any level to play
 */
private void displayDevKeyDialog() {

    Dialog<String> dialog = new Dialog<>();
    dialog.setTitle("Developer mode");
    dialog.setHeaderText("Enter developer key");
    dialog.initOwner(mGameStage);
    dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/lockpad.png").toExternalForm()));

    ButtonType loginButtonType = new ButtonType("Enter", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 20));

    PasswordField password = new PasswordField();
    password.setPromptText("Key");

    grid.add(new Label("Key:"), 0, 1);
    grid.add(password, 1, 1);

    Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
    loginButton.setDisable(true);

    password.textProperty().addListener((observable, oldValue, newValue) -> {
        loginButton.setDisable(newValue.trim().isEmpty());
    });

    dialog.getDialogPane().setContent(grid);

    Platform.runLater(password::requestFocus);

    dialog.setResultConverter(dialogButton -> {
        if (dialogButton == loginButtonType) {
            return password.getText();
        }
        return null;
    });

    Optional<String> result = dialog.showAndWait();

    result.ifPresent(usernamePassword -> {
        /*
         * Encode your own key and place below
         */
        String encodedPass = cryptWithMD5(result.get());
        if(encodedPass != null && encodedPass.equals("efd71744ab79091beef4a125935a73")){
            mDevMode = true;
            playerLogOut();
        } else {
            mDevMode = false;
            Toast.makeText(mGameStage, "Authentication error", TOAST_LENGTH_SHORT);
        }
    });
}
 
開發者ID:nwg-piotr,項目名稱:EistReturns,代碼行數:60,代碼來源:Utils.java

示例13: displayLogInDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
private void displayLogInDialog() {

        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Player login");
        dialog.setHeaderText("Login to the Hall Of Fame");
        dialog.initOwner(mGameStage);

        dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/login.png").toExternalForm()));

        ButtonType newButtonType = new ButtonType("New player", ButtonData.OTHER);
        ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(newButtonType, loginButtonType, ButtonType.CANCEL);

        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField username = new TextField();
        username.setPromptText("Name");
        PasswordField password = new PasswordField();
        password.setPromptText("Password");

        grid.add(new Label("Player name:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Password:"), 0, 1);
        grid.add(password, 1, 1);

        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

        Node newButton = dialog.getDialogPane().lookupButton(newButtonType);
        newButton.setDisable(true);

        username.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
            newButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
        });

        password.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
            newButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
        });

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(username::requestFocus);

        mNewPlayer = false;

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }
            if (dialogButton == newButtonType) {
                mNewPlayer = true;
                return new Pair<>(username.getText(), password.getText());
            }
            return null;
        });

        Optional<Pair<String, String>> result = dialog.showAndWait();

        result.ifPresent(usernamePassword -> {

            if (!mNewPlayer) {
                playerLogin(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
            } else {
                playerNew(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
            }

        });
    }
 
開發者ID:nwg-piotr,項目名稱:EistReturns,代碼行數:74,代碼來源:Utils.java

示例14: displayManagePlayerDialog

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
private void displayManagePlayerDialog() {

        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Manage players");
        dialog.setHeaderText("Select player account");
        dialog.initOwner(mGameStage);

        dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/login.png").toExternalForm()));

        ButtonType newButtonType = new ButtonType("New player", ButtonData.OK_DONE);
        ButtonType loginButtonType = new ButtonType("Delete player", ButtonData.OTHER);
        dialog.getDialogPane().getButtonTypes().addAll(newButtonType, loginButtonType, ButtonType.CANCEL);

        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField username = new TextField();
        username.setPromptText("Name");
        PasswordField password = new PasswordField();
        password.setPromptText("Password");

        grid.add(new Label("Player name:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Password:"), 0, 1);
        grid.add(password, 1, 1);

        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

        Node newButton = dialog.getDialogPane().lookupButton(newButtonType);
        newButton.setDisable(true);

        username.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
            newButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
        });

        password.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
            newButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
        });

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(username::requestFocus);

        mNewPlayer = false;

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }
            if (dialogButton == newButtonType) {
                mNewPlayer = true;
                return new Pair<>(username.getText(), password.getText());
            }
            return null;
        });

        Optional<Pair<String, String>> result = dialog.showAndWait();

        result.ifPresent(usernamePassword -> {

            if (!mNewPlayer) {
                playerDelete(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));

            } else {
                playerNew(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
            }

        });
    }
 
開發者ID:nwg-piotr,項目名稱:EistReturns,代碼行數:75,代碼來源:Utils.java

示例15: showPrefs

import javafx.scene.control.Dialog; //導入方法依賴的package包/類
/**
 * Shows the preferences window.
 */
@SuppressWarnings("unchecked")
@FXML
public void showPrefs() {
  TabPane tabs = new TabPane();
  tabs.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);

  tabs.getTabs().add(new Tab("Application", new ExtendedPropertySheet(AppPreferences.getInstance().getProperties())));

  for (Plugin plugin : PluginLoader.getDefault().getLoadedPlugins()) {
    if (plugin.getProperties().isEmpty()) {
      continue;
    }
    Tab tab = new Tab(plugin.getName());
    tab.setContent(new ExtendedPropertySheet(plugin.getProperties()));

    tab.setDisable(DashboardMode.getCurrentMode() == DashboardMode.PLAYBACK);
    tabs.getTabs().add(tab);
  }

  Dialog<Boolean> dialog = new Dialog<>();
  EasyBind.listBind(dialog.getDialogPane().getStylesheets(), root.getStylesheets());
  dialog.getDialogPane().setContent(new BorderPane(tabs));
  dialog.initOwner(root.getScene().getWindow());
  dialog.initModality(Modality.APPLICATION_MODAL);
  dialog.initStyle(StageStyle.UTILITY);
  dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
  dialog.setTitle("Shuffleboard Preferences");
  dialog.setResizable(true);
  dialog.setResultConverter(button -> !button.getButtonData().isCancelButton());
  if (dialog.showAndWait().orElse(false)) {
    tabs.getTabs().stream()
        .map(t -> (ExtendedPropertySheet) t.getContent())
        .flatMap(p -> p.getItems().stream())
        .flatMap(TypeUtils.castStream(ExtendedPropertySheet.PropertyItem.class))
        .map(i -> (Optional<ObservableValue>) i.getObservableValue())
        .flatMap(TypeUtils.optionalStream())
        .flatMap(TypeUtils.castStream(FlushableProperty.class))
        .filter(FlushableProperty::isChanged)
        .forEach(FlushableProperty::flush);
  }
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:45,代碼來源:MainWindowController.java


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