当前位置: 首页>>代码示例>>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;未经允许,请勿转载。