类javafx.scene.control.DialogPane源码实例Demo

下面列出了怎么用javafx.scene.control.DialogPane的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: RentLio   文件: LoginUIController.java
@FXML
private void adminLoginAction(){
    String userName = txtAdminUserName.getText();
    String password = txtAdminPassword.getText();

    if (!userName.isEmpty() && !password.isEmpty()){
        for (AdminDTO adminDTO: adminDTOList
             ) {
            if (adminDTO.getAdminName().equals(userName) && adminDTO.getPassword().equals(password)){
                loadDashBoardUI();
            }else {
                Alert adminLoginFailedAlert = new Alert(Alert.AlertType.ERROR);
                DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
                dialogPane
                        .getStylesheets().add(getClass()
                        .getResource("/css/dialog-pane-styles.css")
                                .toExternalForm());
                dialogPane.getStyleClass().add("myDialog");
                adminLoginFailedAlert.setTitle("Admin Login");
                adminLoginFailedAlert.setHeaderText("Admin Login failed");
                adminLoginFailedAlert.setContentText("Please check your user name or password again.");
                adminLoginFailedAlert.showAndWait();
            }
        }
    }
}
 
源代码2 项目: AsciidocFX   文件: AlertHelper.java
public static void showDuplicateWarning(List<String> duplicatePaths, Path lib) {
    Alert alert = new WindowModalAlert(Alert.AlertType.WARNING);

    DialogPane dialogPane = alert.getDialogPane();

    ListView listView = new ListView();
    listView.getStyleClass().clear();
    ObservableList items = listView.getItems();
    items.addAll(duplicatePaths);
    listView.setEditable(false);

    dialogPane.setContent(listView);

    alert.setTitle("Duplicate JARs found");
    alert.setHeaderText(String.format("Duplicate JARs found, it may cause unexpected behaviours.\n\n" +
            "Please remove the older versions from these pair(s) manually. \n" +
            "JAR files are located at %s directory.", lib));
    alert.getButtonTypes().clear();
    alert.getButtonTypes().addAll(ButtonType.OK);
    alert.showAndWait();
}
 
源代码3 项目: tcMenu   文件: UIMenuItemTestBase.java
@SuppressWarnings("unchecked")
protected void init(Stage stage) {
    manager = mock(CodePluginManager.class);
    ConfigurationStorage storage = mock(ConfigurationStorage.class);
    editorUI = new CurrentProjectEditorUIImpl(manager, stage, mock(EmbeddedPlatforms.class),
            mock(ArduinoLibraryInstaller.class), storage);
    menuTree = TestUtils.buildCompleteTree();
    mockedConsumer = mock(BiConsumer.class);
    this.stage = stage;

    dialogPane = new DialogPane();
    dialogPane.setMinSize(500, 500);
    stage.setScene(new Scene(dialogPane));
}
 
源代码4 项目: kafka-message-tool   文件: UserGuiInteractor.java
@Override
public void showConfigEntriesInfoDialog(String title,
                                        String header,
                                        ConfigEntriesView entriesView) {
    final Alert alert = getConfigEntriesViewDialog(header);
    alert.setTitle(title);
    final DialogPane dialogPane = alert.getDialogPane();
    dialogPane.setContent(entriesView);
    alert.setResizable(true);
    alert.showAndWait();

}
 
源代码5 项目: kafka-message-tool   文件: UserGuiInteractor.java
private static void applyStylesheetTo(Dialog dialog) {
    DialogPane dialogPane = dialog.getDialogPane();

    dialogPane.getStylesheets().add(
        Thread.currentThread()
            .getClass()
            .getResource(ApplicationConstants.GLOBAL_CSS_FILE_NAME)
            .toExternalForm());
}
 
源代码6 项目: Animu-Downloaderu   文件: LoadDialog.java
public static void stopDialog() {
	if (alert != null && alert.isShowing()) {
		Platform.runLater(() -> {
			DialogPane dialogPane = alert.getDialogPane();
			dialogPane.getButtonTypes().clear();
			dialogPane.getButtonTypes().add(ButtonType.CANCEL);
			alert.close();
		});
	}
}
 
源代码7 项目: RentLio   文件: AlertBuilder.java
private void errorAlert(){
    Alert adminLoginFailedAlert = new Alert(Alert.AlertType.ERROR);
    DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
    dialogPane.getStylesheets().add(
            getClass().getResource("/css/dialog-pane-styles.css")
                    .toExternalForm());
    dialogPane.getStyleClass().add("myDialog");
    adminLoginFailedAlert.setTitle(title);
    adminLoginFailedAlert.setHeaderText(headerText);
    adminLoginFailedAlert.setContentText(contentText);
    adminLoginFailedAlert.showAndWait();
}
 
源代码8 项目: RentLio   文件: AlertBuilder.java
private void infoAlert(){
    Alert adminLoginFailedAlert = new Alert(Alert.AlertType.INFORMATION);
    DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
    dialogPane.getStylesheets().add(
            getClass().getResource("/css/dialog-pane-styles.css")
                    .toExternalForm());
    dialogPane.getStyleClass().add("myDialog");
    adminLoginFailedAlert.setTitle(title);
    adminLoginFailedAlert.setHeaderText(headerText);
    adminLoginFailedAlert.setContentText(contentText);
    adminLoginFailedAlert.showAndWait();
}
 
源代码9 项目: RentLio   文件: AlertBuilder.java
private void warnAlert(){
    Alert adminLoginFailedAlert = new Alert(Alert.AlertType.WARNING);
    DialogPane dialogPane = adminLoginFailedAlert.getDialogPane();
    dialogPane.getStylesheets().add(
            getClass().getResource("/css/dialog-pane-styles.css")
                    .toExternalForm());
    dialogPane.getStyleClass().add("myDialog");
    adminLoginFailedAlert.setTitle(title);
    adminLoginFailedAlert.setHeaderText(headerText);
    adminLoginFailedAlert.setContentText(contentText);
    adminLoginFailedAlert.showAndWait();
}
 
源代码10 项目: G-Earth   文件: ConfirmationDialog.java
public static Alert createAlertWithOptOut(Alert.AlertType type, String dialogKey, String title, String headerText,
                                          String message, String optOutMessage, /*Callback<Boolean, Void> optOutAction,*/
                                          ButtonType... buttonTypes) {
    Alert alert = new Alert(type);
    // Need to force the alert to layout in order to grab the graphic,
    // as we are replacing the dialog pane with a custom pane
    alert.getDialogPane().applyCss();
    Node graphic = alert.getDialogPane().getGraphic();
    // Create a new dialog pane that has a checkbox instead of the hide/show details button
    // Use the supplied callback for the action of the checkbox
    alert.setDialogPane(new DialogPane() {
        @Override
        protected Node createDetailsButton() {
            CheckBox optOut = new CheckBox();
            optOut.setText(optOutMessage);
            optOut.setOnAction(event -> {
                if (optOut.isSelected()) {
                    ignoreDialogs.add(dialogKey);
                }
            });
            return optOut;
        }
    });
    alert.getDialogPane().getButtonTypes().addAll(buttonTypes);
    alert.getDialogPane().setContentText(message);
    // Fool the dialog into thinking there is some expandable content
    // a Group won't take up any space if it has no children
    alert.getDialogPane().setExpandableContent(new Group());
    alert.getDialogPane().setExpanded(true);
    // Reset the dialog graphic using the default style
    alert.getDialogPane().setGraphic(graphic);
    alert.setTitle(title);
    alert.setHeaderText(headerText);
    return alert;
}
 
源代码11 项目: dctb-utfpr-2018-1   文件: GUIController.java
public void showInformationEraseAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.CONFIRMATION);
    
    aboutInfo.setTitle("Operação de remoção");
    aboutInfo.setHeaderText("Remoção bem sucedida!");
    aboutInfo.setContentText("Operação de remoção concluída!");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
源代码12 项目: dctb-utfpr-2018-1   文件: GUIController.java
public void showAboutInformationAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
    
    aboutInfo.setTitle("Sobre o Software");
    aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
    aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
源代码13 项目: dctb-utfpr-2018-1   文件: GUIController.java
public void showInformationEraseAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.CONFIRMATION);
    
    aboutInfo.setTitle("Operação de remoção");
    aboutInfo.setHeaderText("Remoção bem sucedida!");
    aboutInfo.setContentText("Operação de remoção concluída!");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
源代码14 项目: dctb-utfpr-2018-1   文件: GUIController.java
public void showAboutInformationAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
    
    aboutInfo.setTitle("Sobre o Software");
    aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
    aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
源代码15 项目: dctb-utfpr-2018-1   文件: GUIController.java
public void showInformationEraseAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.CONFIRMATION);
    
    aboutInfo.setTitle("Operação de remoção");
    aboutInfo.setHeaderText("Remoção bem sucedida!");
    aboutInfo.setContentText("Operação de remoção concluída!");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
源代码16 项目: dctb-utfpr-2018-1   文件: GUIController.java
public void showAboutInformationAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
    
    aboutInfo.setTitle("Sobre o Software");
    aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
    aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
源代码17 项目: phoebus   文件: PasswordDialog.java
/** @param title Title, message
 *  @param correct_password Password to check
 */
public PasswordDialog(final String title, final String correct_password)
{
    this.correct_password = correct_password;
    final DialogPane pane = getDialogPane();

    pass_entry.setPromptText(Messages.Password_Prompt);
    pass_entry.setMaxWidth(Double.MAX_VALUE);

    HBox.setHgrow(pass_entry, Priority.ALWAYS);

    pane.setContent(new HBox(6, pass_caption, pass_entry));

    pane.setMinSize(300, 150);
    setResizable(true);

    setTitle(Messages.Password);
    setHeaderText(title);
    pane.getStyleClass().add("text-input-dialog");
    pane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    // Check password in dialog?
    if (correct_password != null  &&  correct_password.length() > 0)
    {
        final Button okButton = (Button) pane.lookupButton(ButtonType.OK);
        okButton.addEventFilter(ActionEvent.ACTION, event ->
        {
            if (! checkPassword())
                event.consume();
        });
    }

    setResultConverter((button) ->
    {
        return button.getButtonData() == ButtonData.OK_DONE ? pass_entry.getText() : null;
    });

    Platform.runLater(() -> pass_entry.requestFocus());
}
 
源代码18 项目: Library-Assistant   文件: AlertMaker.java
private static void styleAlert(Alert alert) {
    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    LibraryAssistantUtil.setStageIcon(stage);

    DialogPane dialogPane = alert.getDialogPane();
    dialogPane.getStylesheets().add(AlertMaker.class.getResource("/resources/dark-theme.css").toExternalForm());
    dialogPane.getStyleClass().add("custom-alert");
}
 
源代码19 项目: VocabHunter   文件: ErrorDialogue.java
public ErrorDialogue(final I18nManager i18nManager, final I18nKey titleKey, final Throwable e, final String... messages) {
    alert = new Alert(AlertType.ERROR);
    alert.setTitle(i18nManager.text(titleKey));
    alert.setHeaderText(headerText(messages));

    TextArea textArea = new TextArea(exceptionText(e));
    VBox expContent = new VBox();
    DialogPane dialoguePane = alert.getDialogPane();

    expContent.getChildren().setAll(new Label(i18nManager.text(ERROR_DETAILS)), textArea);
    dialoguePane.setExpandableContent(expContent);
    dialoguePane.expandedProperty().addListener(p -> Platform.runLater(this::resizeAlert));
    dialoguePane.setId("errorDialogue");
}
 
源代码20 项目: markdown-writer-fx   文件: LinkDialog.java
public LinkDialog(Window owner, Path basePath) {
	setTitle(Messages.get("LinkDialog.title"));
	initOwner(owner);
	setResizable(true);

	initComponents();

	linkBrowseDirectoyButton.setBasePath(basePath);
	linkBrowseDirectoyButton.urlProperty().bindBidirectional(urlField.escapedTextProperty());

	linkBrowseFileButton.setBasePath(basePath);
	linkBrowseFileButton.urlProperty().bindBidirectional(urlField.escapedTextProperty());

	DialogPane dialogPane = getDialogPane();
	dialogPane.setContent(pane);
	dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

	dialogPane.lookupButton(ButtonType.OK).disableProperty().bind(
			urlField.escapedTextProperty().isEmpty());

	Utils.fixSpaceAfterDeadKey(dialogPane.getScene());

	link.bind(Bindings.when(titleField.escapedTextProperty().isNotEmpty())
			.then(Bindings.format("[%s](%s \"%s\")", textField.escapedTextProperty(), urlField.escapedTextProperty(), titleField.escapedTextProperty()))
			.otherwise(Bindings.when(textField.escapedTextProperty().isNotEmpty())
					.then(Bindings.format("[%s](%s)", textField.escapedTextProperty(), urlField.escapedTextProperty()))
					.otherwise(Bindings.format("<%s>", urlField.escapedTextProperty()))));
	previewField.textProperty().bind(link);

	setResultConverter(dialogButton -> {
		return (dialogButton == ButtonType.OK) ? link.get() : null;
	});

	Platform.runLater(() -> {
		urlField.requestFocus();

		if (urlField.getText().startsWith("http://"))
			urlField.selectRange("http://".length(), urlField.getLength());
	});
}
 
源代码21 项目: markdown-writer-fx   文件: ImageDialog.java
public ImageDialog(Window owner, Path basePath) {
	setTitle(Messages.get("ImageDialog.title"));
	initOwner(owner);
	setResizable(true);

	initComponents();

	linkBrowseFileButton.setBasePath(basePath);
	linkBrowseFileButton.addExtensionFilter(new ExtensionFilter(Messages.get("ImageDialog.chooser.imagesFilter"), "*.png", "*.gif", "*.jpg", "*.svg"));
	linkBrowseFileButton.urlProperty().bindBidirectional(urlField.escapedTextProperty());

	DialogPane dialogPane = getDialogPane();
	dialogPane.setContent(pane);
	dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

	dialogPane.lookupButton(ButtonType.OK).disableProperty().bind(
			urlField.escapedTextProperty().isEmpty()
				.or(textField.escapedTextProperty().isEmpty()));

	Utils.fixSpaceAfterDeadKey(dialogPane.getScene());

	image.bind(Bindings.when(titleField.escapedTextProperty().isNotEmpty())
			.then(Bindings.format("![%s](%s \"%s\")", textField.escapedTextProperty(), urlField.escapedTextProperty(), titleField.escapedTextProperty()))
			.otherwise(Bindings.format("![%s](%s)", textField.escapedTextProperty(), urlField.escapedTextProperty())));
	previewField.textProperty().bind(image);

	setResultConverter(dialogButton -> {
		return (dialogButton == ButtonType.OK) ? image.get() : null;
	});

	Platform.runLater(() -> {
		urlField.requestFocus();

		if (urlField.getText().startsWith("http://"))
			urlField.selectRange("http://".length(), urlField.getLength());
	});
}
 
源代码22 项目: AsciidocFX   文件: AlertHelper.java
public static Optional<String> showOldConfiguration(List<String> paths) {
    Alert alert = new WindowModalAlert(AlertType.INFORMATION);

    DialogPane dialogPane = alert.getDialogPane();

    ListView listView = new ListView();
    listView.getStyleClass().clear();
    ObservableList items = listView.getItems();
    items.addAll(paths);
    listView.setEditable(false);

    dialogPane.setContent(listView);

    alert.setTitle("Load previous configuration?");
    alert.setHeaderText(String.format("You have configuration files from previous AsciidocFX versions\n\n" +
            "Select the configuration which you want to load configuration \n" +
            "or continue with fresh configuration"));
    alert.getButtonTypes().clear();
    alert.getButtonTypes().addAll(ButtonType.APPLY);
    alert.getButtonTypes().addAll(ButtonType.CANCEL);
    ButtonType buttonType = alert.showAndWait().orElse(ButtonType.CANCEL);

    Object selectedItem = listView.getSelectionModel().getSelectedItem();
    return (buttonType == ButtonType.APPLY) ?
            Optional.ofNullable((String) selectedItem) :
            Optional.empty();
}
 
源代码23 项目: AsciidocFX   文件: DefenderDialog.java
default void setDefaultIcon(DialogPane dialog) {
    Stage stage = (Stage) dialog.getScene().getWindow();
    try (InputStream logoStream = DefenderDialog.class.getResourceAsStream("/logo.png")) {
        stage.getIcons().add(new Image(logoStream));
    } catch (IOException e) {
        logger.error("logo.png is not found", e);
    }
}
 
源代码24 项目: sis   文件: WKTPane.java
public static void showDialog(Object parent, FormattableObject candidate){
    final WKTPane chooser = new WKTPane(candidate);

    final Alert alert = new Alert(Alert.AlertType.NONE);
    final DialogPane pane = alert.getDialogPane();
    pane.setContent(chooser);
    alert.getButtonTypes().setAll(ButtonType.OK);
    alert.setResizable(true);
    alert.showAndWait();
}
 
源代码25 项目: sis   文件: CRSChooser.java
/**
 * Show a modal dialog to select a {@link CoordinateReferenceSystem}.
 *
 * @param parent parent frame of widget.
 * @param crs {@link CoordinateReferenceSystem} to edit.
 * @return modified {@link CoordinateReferenceSystem}.
 */
public static CoordinateReferenceSystem showDialog(Object parent, CoordinateReferenceSystem crs) {
    final CRSChooser chooser = new CRSChooser();
    chooser.crsProperty.set(crs);
    final Alert alert = new Alert(Alert.AlertType.NONE);
    final DialogPane pane = alert.getDialogPane();
    pane.setContent(chooser);
    alert.getButtonTypes().setAll(ButtonType.OK,ButtonType.CANCEL);
    alert.setResizable(true);
    final ButtonType res = alert.showAndWait().orElse(ButtonType.CANCEL);
    return res == ButtonType.CANCEL ? null : chooser.crsProperty.get();
}
 
源代码26 项目: mzmine3   文件: CombinedModuleSetHighlightDialog.java
public CombinedModuleSetHighlightDialog(@Nonnull Stage parent, @Nonnull CombinedModulePlot plot,
    @Nonnull String command) {

  desktop = MZmineCore.getDesktop();
  this.plot = plot;
  rangeType = command;
  mainPane = new DialogPane();
  mainScene = new Scene(mainPane);

  // Use main CSS
  mainScene.getStylesheets()
      .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());
  setScene(mainScene);

  initOwner(parent);

  String title = "Highlight ";
  if (command.equals("HIGHLIGHT_PRECURSOR")) {
    title += "precursor m/z range";
    axis = plot.getXYPlot().getDomainAxis();
  } else if (command.equals("HIGHLIGHT_NEUTRALLOSS")) {
    title += "neutral loss m/z range";
    axis = plot.getXYPlot().getRangeAxis();
  }
  setTitle(title);

  Label lblMinMZ = new Label("Minimum m/z");
  Label lblMaxMZ = new Label("Maximum m/z");

  NumberStringConverter converter = new NumberStringConverter();

  fieldMinMZ = new TextField();
  fieldMinMZ.setTextFormatter(new TextFormatter<>(converter));
  fieldMaxMZ = new TextField();
  fieldMaxMZ.setTextFormatter(new TextFormatter<>(converter));

  pnlLabelsAndFields = new GridPane();
  pnlLabelsAndFields.setHgap(5);
  pnlLabelsAndFields.setVgap(10);

  int row = 0;
  pnlLabelsAndFields.add(lblMinMZ, 0, row);
  pnlLabelsAndFields.add(fieldMinMZ, 1, row);

  row++;
  pnlLabelsAndFields.add(lblMaxMZ, 0, row);
  pnlLabelsAndFields.add(fieldMaxMZ, 1, row);

  // Create buttons
  mainPane.getButtonTypes().add(ButtonType.OK);
  mainPane.getButtonTypes().add(ButtonType.CANCEL);

  btnOK = (Button) mainPane.lookupButton(ButtonType.OK);
  btnOK.setOnAction(e -> {
    if (highlightDataPoints()) {
      hide();
    }
  });
  btnCancel = (Button) mainPane.lookupButton(ButtonType.CANCEL);
  btnCancel.setOnAction(e -> hide());

  mainPane.setContent(pnlLabelsAndFields);

  sizeToScene();
  centerOnScreen();
  setResizable(false);

}
 
public ProductIonFilterSetHighlightDialog(@Nonnull Stage parent, ProductIonFilterPlot plot,
    String command) {

  this.desktop = MZmineCore.getDesktop();
  this.plot = plot;
  this.rangeType = command;
  mainPane = new DialogPane();
  mainScene = new Scene(mainPane);
  mainScene.getStylesheets()
      .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());
  setScene(mainScene);
  initOwner(parent);
  String title = "Highlight ";
  if (command.equals("HIGHLIGHT_PRECURSOR")) {
    title += "precursor m/z range";
    axis = plot.getXYPlot().getDomainAxis();
  } else if (command.equals("HIGHLIGHT_NEUTRALLOSS")) {
    title += "neutral loss m/z range";
    axis = plot.getXYPlot().getRangeAxis();
  }
  setTitle(title);

  Label lblMinMZ = new Label("Minimum m/z");
  Label lblMaxMZ = new Label("Maximum m/z");

  NumberStringConverter converter = new NumberStringConverter();

  fieldMinMZ = new TextField();
  fieldMinMZ.setTextFormatter(new TextFormatter<>(converter));
  fieldMaxMZ = new TextField();
  fieldMaxMZ.setTextFormatter(new TextFormatter<>(converter));

  pnlLabelsAndFields = new GridPane();
  pnlLabelsAndFields.setHgap(5);
  pnlLabelsAndFields.setVgap(10);

  int row = 0;
  pnlLabelsAndFields.add(lblMinMZ, 0, row);
  pnlLabelsAndFields.add(fieldMinMZ, 1, row);

  row++;
  pnlLabelsAndFields.add(lblMaxMZ, 0, row);
  pnlLabelsAndFields.add(fieldMaxMZ, 1, row);

  // Create buttons
  mainPane.getButtonTypes().add(ButtonType.OK);
  mainPane.getButtonTypes().add(ButtonType.CANCEL);

  btnOK = (Button) mainPane.lookupButton(ButtonType.OK);
  btnOK.setOnAction(e -> {
    if (highlightDataPoints()) {
      hide();
    }
  });
  btnCancel = (Button) mainPane.lookupButton(ButtonType.CANCEL);
  btnCancel.setOnAction(e -> hide());

  mainPane.setContent(pnlLabelsAndFields);

  sizeToScene();
  centerOnScreen();
  setResizable(false);
}
 
源代码28 项目: markdown-writer-fx   文件: OptionsDialog.java
public OptionsDialog(Window owner) {
	setTitle(Messages.get("OptionsDialog.title"));
	initOwner(owner);

	initComponents();

	tabPane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);

	// add "Store in project" checkbox to buttonbar
	boolean oldStoreInProject = Options.isStoreInProject();
	ButtonType storeInProjectButtonType = new ButtonType(Messages.get("OptionsDialog.storeInProject.text"), ButtonData.LEFT);
	setDialogPane(new DialogPane() {
		@Override
		protected Node createButton(ButtonType buttonType) {
			if (buttonType == storeInProjectButtonType) {
				CheckBox storeInProjectButton = new CheckBox(buttonType.getText());
				ButtonBar.setButtonData(storeInProjectButton, buttonType.getButtonData());
				storeInProjectButton.setSelected(oldStoreInProject);
				storeInProjectButton.setDisable(ProjectManager.getActiveProject() == null);
				return storeInProjectButton;
			}
			return super.createButton(buttonType);
		}
	});

	DialogPane dialogPane = getDialogPane();
	dialogPane.setContent(tabPane);
	dialogPane.getButtonTypes().addAll(storeInProjectButtonType, ButtonType.OK, ButtonType.CANCEL);

	// save options on OK clicked
	dialogPane.lookupButton(ButtonType.OK).addEventHandler(ActionEvent.ACTION, e -> {
		boolean newStoreInProject = ((CheckBox)dialogPane.lookupButton(storeInProjectButtonType)).isSelected();
		if (newStoreInProject != oldStoreInProject)
			Options.storeInProject(newStoreInProject);

		save();
		e.consume();
	});

	Utils.fixSpaceAfterDeadKey(dialogPane.getScene());

	// load options
	load();

	// select last tab
	int tabIndex = MarkdownWriterFXApp.getState().getInt("lastOptionsTab", -1);
	if (tabIndex > 0 && tabIndex < tabPane.getTabs().size())
		tabPane.getSelectionModel().select(tabIndex);

	// remember last selected tab
	setOnHidden(e -> {
		MarkdownWriterFXApp.getState().putInt("lastOptionsTab", tabPane.getSelectionModel().getSelectedIndex());
	});
}
 
源代码29 项目: AsciidocFX   文件: TextDialog.java
private static void showAlwaysOnTop(DialogPane dialogPane) {
    ((Stage) dialogPane.getScene().getWindow()).setAlwaysOnTop(true);
}
 
源代码30 项目: AsciidocFX   文件: AlertHelper.java
static Alert buildDeleteAlertDialog(List<Path> pathsLabel) {
    Alert deleteAlert = new WindowModalAlert(Alert.AlertType.WARNING, null, ButtonType.YES, ButtonType.CANCEL);
    deleteAlert.setHeaderText("Do you want to delete selected path(s)?");
    DialogPane dialogPane = deleteAlert.getDialogPane();

    ObservableList<Path> paths = Optional.ofNullable(pathsLabel)
            .map(FXCollections::observableList)
            .orElse(FXCollections.emptyObservableList());

    if (paths.isEmpty()) {
        dialogPane.setContentText("There are no files selected.");
        deleteAlert.getButtonTypes().clear();
        deleteAlert.getButtonTypes().add(ButtonType.CANCEL);
        return deleteAlert;
    }

    ListView<Path> listView = new ListView<>(paths);
    listView.setId("listOfPaths");

    GridPane gridPane = new GridPane();
    gridPane.addRow(0, listView);
    GridPane.setHgrow(listView, Priority.ALWAYS);

    double minWidth = 200.0;
    double maxWidth = Screen.getScreens().stream()
            .mapToDouble(s -> s.getBounds().getWidth() / 3)
            .min().orElse(minWidth);

    double prefWidth = paths.stream()
            .map(String::valueOf)
            .mapToDouble(s -> s.length() * 7)
            .max()
            .orElse(maxWidth);

    double minHeight = IntStream.of(paths.size())
            .map(e -> e * 70)
            .filter(e -> e <= 300 && e >= 70)
            .findFirst()
            .orElse(200);

    gridPane.setMinWidth(minWidth);
    gridPane.setPrefWidth(prefWidth);
    gridPane.setPrefHeight(minHeight);
    dialogPane.setContent(gridPane);
    return deleteAlert;
}
 
 类所在包
 同包方法