當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。