当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.initModality方法代码示例

本文整理汇总了Java中javafx.scene.control.Dialog.initModality方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.initModality方法的具体用法?Java Dialog.initModality怎么用?Java Dialog.initModality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.Dialog的用法示例。


在下文中一共展示了Dialog.initModality方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
 * Create the dialog for entering a String.
 *
 * @param prompt the string message to prompt the user with
 * @return the controller of the dialog window, enabling to display the dialog and read the selected result
 */
public EnterStringController create(String prompt) {
    FXMLLoader fxmlLoader = this.fxmlLoader.get();
    DialogPane dialogPane = null;
    try (InputStream is = getClass().getResourceAsStream("EnterStringDialogPane.fxml")) {
        dialogPane = fxmlLoader.load(is);
    } catch (IOException e) {
        AlertCreator.handleLoadLayoutError(fxmlLoader.getResources(), e);
    }
    dialogPane.setHeaderText(prompt);
    EnterStringController enterStringController = fxmlLoader.getController();
    Dialog<ButtonType> dialog = new Dialog<>();
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setDialogPane(dialogPane);
    enterStringController.setDialog(dialog);
    dialog.setTitle("StudyGuide");
    dialog.setOnShown(event -> enterStringController.getTextField().requestFocus());
    return enterStringController;
}
 
开发者ID:oskopek,项目名称:StudyGuide,代码行数:25,代码来源:EnterStringDialogPaneCreator.java

示例2: getDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public Dialog<String[]> getDialog(ButtonType ok) {
	Dialog<String[]> dialog = new Dialog<String[]>();
	dialog.setTitle(Values.MAIN_TITLE);
	dialog.setHeaderText(null);

	dialog.initModality(Modality.APPLICATION_MODAL);

	// 自定义确认和取消按钮
	ButtonType cancel = new ButtonType(Values.CANCEL, ButtonData.CANCEL_CLOSE);
	dialog.getDialogPane().getButtonTypes().addAll(ok, cancel);
	return dialog;
}
 
开发者ID:zhazhapan,项目名称:qiniu,代码行数:13,代码来源: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: createBasicDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
private Dialog<ButtonType> createBasicDialog(final String title, final String message) {
    Dialog<ButtonType> d = new Dialog<>();
    d.setTitle(title);
    d.setContentText(message);
    d.initModality(Modality.APPLICATION_MODAL);
    d.initStyle(StageStyle.UNDECORATED);
    return d;
}
 
开发者ID:Vogel612,项目名称:TranslationHelper,代码行数:9,代码来源:JFXDialog.java

示例5: 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

示例6: newDialog

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
 * Get a modal dialog with the application icon
 */
public static <T> Dialog<T> newDialog(String title, ButtonType...buttonTypes){
    Dialog<T> result = new Dialog<T>();
    result.setTitle(title);
    result.initModality(Modality.APPLICATION_MODAL);
    result.getDialogPane().getButtonTypes().addAll(buttonTypes);
    ((Stage)result.getDialogPane().getScene().getWindow()).getIcons().addAll(ICON_IMAGE_VIEW.getImage());
    return result;
}
 
开发者ID:yevster,项目名称:spdx-edit,代码行数:12,代码来源:UiUtils.java

示例7: exception

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static void exception(Throwable throwable) {
	System.err.println("Exception being directed to FXUtil.exception, which is not showing anything at this point because it is not being invoked by the JavaFX thread: " + throwable);

	Dialog<ButtonType> dialog = new Dialog<ButtonType>();

	dialog.setTitle("Program exception");

	final DialogPane dialogPane = dialog.getDialogPane();
	dialogPane.setContentText("Details of the problem:");
	dialogPane.getButtonTypes().addAll(ButtonType.OK);
	dialogPane.setContentText(throwable.getMessage());
	dialog.initModality(Modality.APPLICATION_MODAL);

	Label label = new Label("Exception stacktrace:");
	StringWriter sw = new StringWriter();
	PrintWriter  pw = new PrintWriter(sw);
	throwable.printStackTrace(pw);
	pw.close();

	TextArea textArea = new TextArea(sw.toString());
	textArea.setEditable(false);
	textArea.setWrapText(true);

	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);
	GridPane.setVgrow(textArea, Priority.ALWAYS);
	GridPane.setHgrow(textArea, Priority.ALWAYS);

	GridPane root = new GridPane();
	root.setVisible(false);
	root.setMaxWidth(Double.MAX_VALUE);
	root.add(label, 0, 0);
	root.add(textArea, 0, 1);
	dialogPane.setExpandableContent(root);
	dialog.showAndWait();
}
 
开发者ID:aic-sri-international,项目名称:aic-praise,代码行数:37,代码来源:FXUtil.java

示例8: 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

示例9: CreateProjectController

import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
 * Default constructor creates a JavaFX 8 Dialog with three input fields for project details
 */
public CreateProjectController() {
	// Create the title, description and tags labels and fields.
	TextField projectName = new TextField();
	projectName.setPromptText("Project Name");
	TextArea projectDescription = new TextArea();
	projectDescription.setMaxHeight(100);
	projectDescription.setPromptText("Project Description");
	TextArea projectTags = new TextArea();
	projectTags.setMaxHeight(50);
	projectTags.setPromptText("Project Tags");
	
	
	GridPane grid = new GridPane();
	grid.setPadding(new Insets(25));
	grid.setHgap(10);
	grid.setVgap(10);
	
	grid.add(new Label("Project Name:"), 0, 0);
	grid.add(projectName, 1, 0);
	grid.add(new Label("Project Description:"), 0, 1);
	grid.add(projectDescription, 1, 1);
	grid.add(new Label("Project Tags:"), 0, 2);
	grid.add(projectTags, 1, 2);
	
	Dialog<List<String>> dialog = new Dialog<>();
	dialog.setTitle("Create Project");
	dialog.initModality(Modality.NONE);

	// Set the button types.
	ButtonType createButtonType = new ButtonType("create", ButtonData.OK_DONE);
	dialog.getDialogPane().getButtonTypes().addAll(createButtonType, ButtonType.CANCEL);
	
	// Enable/Disable create button depending on whether a project name was entered.
	Node loginButton = dialog.getDialogPane().lookupButton(createButtonType);
	loginButton.setDisable(true);

	// Check if project name entered and disable create button until then
	projectName.textProperty().addListener((observable, oldValue, newValue) -> {
		loginButton.setDisable(newValue.trim().isEmpty());
	});

	dialog.getDialogPane().setContent(grid);

	// Request focus on the project name field by default.
	Platform.runLater(() -> projectName.requestFocus());

	// Convert the result to a an arraylist when create button is clicked.
	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == createButtonType) {
			List<String> vals = new ArrayList<>();
			vals.add(projectName.getText());
			vals.add(projectDescription.getText());
			vals.add(projectTags.getText());
			return vals;
		}

		return null;
	});

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

	result.ifPresent(r -> {
		project = Project.newProject(p -> {
			p.setName(r.get(0).toString());
			p.setDescription(r.get(1).toString());
			p.setTags(sliceTags(r.get(2).toString()));
		});
	});

}
 
开发者ID:chilloutman,项目名称:photo-flow,代码行数:74,代码来源:CreateProjectController.java


注:本文中的javafx.scene.control.Dialog.initModality方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。