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

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

源代码1 项目: img2latex-mathpix   文件: UIUtils.java
/**
 * Display an error alert dialog.
 *
 * @param error error message to be displayed.
 */
public static void displayError(String error) {

    var alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Error");

    // Clear default OK button
    alert.getButtonTypes().clear();
    var okButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
    alert.getButtonTypes().addAll(okButtonType);

    // set no header area in the dialog
    alert.setHeaderText(null);
    alert.setContentText(error);

    var stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.showAndWait();

}
 
源代码2 项目: PDF4Teachers   文件: Document.java
public boolean save(){

        if(Edition.isSave()){
            return true;
        }

        if(Main.settings.isAutoSave()){
            edition.save();
        }else{
            Alert alert = Builders.getAlert(Alert.AlertType.CONFIRMATION, TR.tr("Édition non sauvegardée"));
            alert.setHeaderText(TR.tr("L'édition du document n'est pas enregistrée."));
            alert.setContentText(TR.tr("Voulez-vous l'enregistrer ?"));
            ButtonType yesButton = new ButtonType(TR.tr("Oui"), ButtonBar.ButtonData.YES);
            ButtonType noButton = new ButtonType(TR.tr("Non"), ButtonBar.ButtonData.NO);
            ButtonType cancelButton = new ButtonType(TR.tr("Annuler"), ButtonBar.ButtonData.CANCEL_CLOSE);
            alert.getButtonTypes().setAll(yesButton, noButton, cancelButton);

            Optional<ButtonType> option = alert.showAndWait();
            if(option.get() == yesButton){
                edition.save(); return true;
            }else{
                return option.get() == noButton;
            }
        }
        return true;
    }
 
源代码3 项目: WorkbenchFX   文件: DialogSkin.java
private void initializeParts() {
  dialogPane = new VBox();
  dialogPane.getStyleClass().add("dialog-pane");

  dialogHeader = new HBox();
  dialogHeader.getStyleClass().add("dialog-header");

  dialogTitle = new Label("Dialog");
  dialogTitle.getStyleClass().add("dialog-title");

  dialogContentPane = new StackPane();
  dialogContentPane.getStyleClass().add("dialog-content-pane");

  dialogButtonBar = new ButtonBar();
  dialogButtonBar.getStyleClass().add("dialog-button-bar");
}
 
源代码4 项目: marathonv5   文件: ModalDialog.java
private ObservableList<Node> getChildren(Node node) {
    if (node instanceof ButtonBar) {
        return ((ButtonBar) node).getButtons();
    }
    if (node instanceof ToolBar) {
        return ((ToolBar) node).getItems();
    }
    if (node instanceof Pane) {
        return ((Pane) node).getChildren();
    }
    if (node instanceof TabPane) {
        ObservableList<Node> contents = FXCollections.observableArrayList();
        ObservableList<Tab> tabs = ((TabPane) node).getTabs();
        for (Tab tab : tabs) {
            contents.add(tab.getContent());
        }
        return contents;
    }
    return FXCollections.observableArrayList();
}
 
源代码5 项目: Motion_Profile_Generator   文件: DialogFactory.java
public static Dialog<Boolean> createAboutDialog()
{
    Dialog<Boolean> dialog = new Dialog<>();

    try
    {
        FXMLLoader loader = new FXMLLoader( ResourceLoader.getResource("/com/mammen/ui/javafx/dialog/about/AboutDialog.fxml") );

        dialog.setDialogPane( loader.load() );

        dialog.setResultConverter( (ButtonType buttonType) -> buttonType.getButtonData() == ButtonBar.ButtonData.CANCEL_CLOSE );
    }
    catch( Exception e )
    {
        e.printStackTrace();
        dialog.getDialogPane().getButtonTypes().add( ButtonType.CLOSE );
    }

    dialog.setTitle( "About" );

    return dialog;
}
 
源代码6 项目: Motion_Profile_Generator   文件: DialogFactory.java
public static Dialog<Boolean> createSettingsDialog()
{
    Dialog<Boolean> dialog = new Dialog<>();

    try
    {
        FXMLLoader loader = new FXMLLoader( ResourceLoader.getResource("/com/mammen/ui/javafx/dialog/settings/SettingsDialog.fxml") );

        dialog.setDialogPane( loader.load() );

        ((Button) dialog.getDialogPane().lookupButton(ButtonType.APPLY)).setDefaultButton(true);
        ((Button) dialog.getDialogPane().lookupButton(ButtonType.CANCEL)).setDefaultButton(false);

        // Some header stuff
        dialog.setTitle("Settings");
        dialog.setHeaderText("Manage settings");

        dialog.setResultConverter( (ButtonType buttonType) -> buttonType.getButtonData() == ButtonBar.ButtonData.APPLY );
    }
    catch( Exception e )
    {
        e.printStackTrace();
    }

    return dialog;
}
 
public void removeTimingInput(ActionEvent fxevent){
    
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Clear Input...");
    alert.setHeaderText("Delete Input:");
    alert.setContentText("Do you want to remove the " +timingLocationInput.getLocationName() + " input?\nThis will clear all reads associated with this input.");

    ButtonType removeButtonType = new ButtonType("Remove",ButtonBar.ButtonData.YES);
    ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(cancelButtonType, removeButtonType );

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == removeButtonType) {
        boolean remove = ((VBox) baseGridPane.getParent()).getChildren().remove(baseGridPane);
        if (timingLocationInput != null) {
            timingLocationDAO.removeTimingLocationInput(timingLocationInput);
        }
    }
}
 
public void clearReads(ActionEvent fxevent){
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Clear times...");
    alert.setHeaderText("Clear Times:");
    alert.setContentText("Are you sure you want to clear all existing times for this input?");

    ButtonType deleteButtonType = new ButtonType("Clear Times",ButtonBar.ButtonData.YES);
    ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(cancelButtonType, deleteButtonType );

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == deleteButtonType) {
        timingLocationInput.clearReads(); 
    }
}
 
源代码9 项目: pcgen   文件: EquipCustomizerDialog.java
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(equipCustomPanel, BorderLayout.CENTER);

	ButtonBar buttonBar = new OKCloseButtonBar(
			this::doOK,
			this::doCancel
	);

	Button buyButton = new Button(LanguageBundle.getString("in_buy"));
	buttonBar.getButtons().add(buyButton);

	pane.add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
	Utility.installEscapeCloseOperation(this);
}
 
源代码10 项目: pcgen   文件: AbstractDialog.java
private void initialize()
{
	OKCloseButtonBar buttonBar = new OKCloseButtonBar(
			evt -> okButtonActionPerformed(),
			evt -> dispose()
	);
	buttonBar.getOkButton().setText(LanguageBundle.getString(getOkKey()));

	if (includeApplyButton())
	{
		Button applyButton = new Button(LanguageBundle.getString("in_apply"));
		applyButton.setOnAction(evt -> applyButtonActionPerformed());
		ButtonBar.setButtonData(applyButton, ButtonBar.ButtonData.APPLY);
		buttonBar.getButtons().add(applyButton);
	}

	getContentPane().setLayout(new BorderLayout());
	getContentPane().add(getCenter(), BorderLayout.CENTER);
	getContentPane().add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
}
 
源代码11 项目: pcgen   文件: SinglePrefDialog.java
/**
 * Create a new modal SinglePrefDialog to display a particular panel.
 *  
 * @param parent The parent frame, used for positioning and to be modal 
 * @param prefsPanel The panel to be displayed.
 */
public SinglePrefDialog(JFrame parent, PCGenPrefsPanel prefsPanel)
{
	super(parent, prefsPanel.getTitle(), true);

	this.prefsPanel = prefsPanel;

	ButtonBar controlPanel = new OKCloseButtonBar(
			this::okButtonActionPerformed,
			this::cancelButtonActionPerformed
	);

	this.getContentPane().setLayout(new BorderLayout());
	this.getContentPane().add(prefsPanel, BorderLayout.CENTER);
	this.getContentPane().add(GuiUtility.wrapParentAsJFXPanel(controlPanel), BorderLayout.PAGE_END);
	prefsPanel.applyOptionValuesToControls();
	pack();
	Utility.installEscapeCloseOperation(this);
}
 
源代码12 项目: archivo   文件: Archivo.java
private void showUpdateDialog(SoftwareUpdateDetails updateDetails) {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Update Available");
    alert.setHeaderText(String.format("A new version of %s is available", Archivo.APPLICATION_NAME));
    alert.setContentText(String.format("%s %s was released on %s.\n\nNotable changes include %s.\n\n" +
                    "Would you like to install the update now?\n\n",
            Archivo.APPLICATION_NAME, updateDetails.getVersion(),
            updateDetails.getReleaseDate().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)),
            updateDetails.getSummary()));

    ButtonType deferButtonType = new ButtonType("No, I'll Update Later", ButtonBar.ButtonData.NO);
    ButtonType updateButtonType = new ButtonType("Yes, Let's Update Now", ButtonBar.ButtonData.YES);

    alert.getButtonTypes().setAll(deferButtonType, updateButtonType);
    ((Button) alert.getDialogPane().lookupButton(deferButtonType)).setDefaultButton(false);
    ((Button) alert.getDialogPane().lookupButton(updateButtonType)).setDefaultButton(true);

    Optional<ButtonType> result = alert.showAndWait();
    if ((result.isPresent() && result.get() == updateButtonType)) {
        try {
            Desktop.getDesktop().browse(updateDetails.getLocation().toURI());
        } catch (URISyntaxException | IOException e) {
            Archivo.logger.error("Error opening a web browser to download '{}': ", updateDetails.getLocation(), e);
        }
    }
}
 
源代码13 项目: archivo   文件: Archivo.java
/**
 * If there are active tasks, prompt the user before exiting.
 * Returns true if the user wants to cancel all tasks and exit.
 */
private boolean confirmTaskCancellation() {
    if (archiveQueueManager.hasTasks()) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("Cancel Task Confirmation");
        alert.setHeaderText("Really cancel all tasks and exit?");
        alert.setContentText("You are currently archiving recordings from your TiVo. Are you sure you want to " +
                "close Archivo and cancel these tasks?");

        ButtonType cancelButtonType = new ButtonType("Cancel tasks and exit", ButtonBar.ButtonData.NO);
        ButtonType keepButtonType = new ButtonType("Keep archiving", ButtonBar.ButtonData.CANCEL_CLOSE);

        alert.getButtonTypes().setAll(cancelButtonType, keepButtonType);
        ((Button) alert.getDialogPane().lookupButton(cancelButtonType)).setDefaultButton(false);
        ((Button) alert.getDialogPane().lookupButton(keepButtonType)).setDefaultButton(true);

        Optional<ButtonType> result = alert.showAndWait();
        if (!result.isPresent()) {
            logger.error("No result from alert dialog");
            return false;
        } else {
            return (result.get() == cancelButtonType);
        }
    }
    return true;
}
 
源代码14 项目: archivo   文件: Archivo.java
private boolean confirmDelete(Recording recording, Tivo tivo) {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Remove Recording Confirmation");
    alert.setHeaderText("Really remove this recording?");
    alert.setContentText(String.format("Are you sure you want to delete %s from %s?",
            recording.getFullTitle(), tivo.getName()));

    ButtonType deleteButtonType = new ButtonType("Delete", ButtonBar.ButtonData.NO);
    ButtonType keepButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(deleteButtonType, keepButtonType);
    ((Button) alert.getDialogPane().lookupButton(deleteButtonType)).setDefaultButton(false);
    ((Button) alert.getDialogPane().lookupButton(keepButtonType)).setDefaultButton(true);

    Optional<ButtonType> result = alert.showAndWait();
    if (!result.isPresent()) {
        logger.error("No result from alert dialog");
        return false;
    } else {
        return (result.get() == deleteButtonType);
    }
}
 
源代码15 项目: HubTurbo   文件: BoardNameDialog.java
private void createButtons() {
    ButtonType submitButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
    getDialogPane().getButtonTypes().addAll(submitButtonType, ButtonType.CANCEL);
    submitButton = (Button) getDialogPane().lookupButton(submitButtonType);
    submitButton.addEventFilter(ActionEvent.ACTION, event -> {
        if (isBoardNameDuplicate(nameField.getText()) && !shouldOverwriteDuplicateBoard()) {
            event.consume();
        }
    });
    submitButton.setId(IdGenerator.getBoardNameSaveButtonId());

    setResultConverter(submit -> {
        if (submit == submitButtonType) {
            return nameField.getText();
        }
        return null;
    });

}
 
源代码16 项目: HubTurbo   文件: DialogMessage.java
public static boolean showYesNoWarningDialog(String title, String header, String message,
                                             String yesButtonLabel, String noButtonLabel) {

    Alert alert = new Alert(Alert.AlertType.WARNING);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(message);

    ButtonType yesButton = new ButtonType(yesButtonLabel, ButtonBar.ButtonData.YES);
    ButtonType noButton = new ButtonType(noButtonLabel, ButtonBar.ButtonData.NO);
    alert.getButtonTypes().setAll(yesButton, noButton);

    Optional<ButtonType> result = alert.showAndWait();

    return result.get().equals(yesButton);
}
 
源代码17 项目: HubTurbo   文件: DialogMessage.java
public static boolean showYesNoConfirmationDialog(String title, String header, String message,
                                             String yesButtonLabel, String noButtonLabel) {

    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(message);

    ButtonType yesButton = new ButtonType(yesButtonLabel, ButtonBar.ButtonData.YES);
    ButtonType noButton = new ButtonType(noButtonLabel, ButtonBar.ButtonData.NO);
    alert.getButtonTypes().setAll(yesButton, noButton);

    Optional<ButtonType> result = alert.showAndWait();

    return result.get().equals(yesButton);
}
 
源代码18 项目: pcgen   文件: EquipCustomizerDialog.java
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(equipCustomPanel, BorderLayout.CENTER);

	ButtonBar buttonBar = new OKCloseButtonBar(
			this::doOK,
			this::doCancel
	);

	Button buyButton = new Button(LanguageBundle.getString("in_buy"));
	buttonBar.getButtons().add(buyButton);

	pane.add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
	Utility.installEscapeCloseOperation(this);
}
 
源代码19 项目: pcgen   文件: AbstractDialog.java
private void initialize()
{
	OKCloseButtonBar buttonBar = new OKCloseButtonBar(
			evt -> okButtonActionPerformed(),
			evt -> dispose()
	);
	buttonBar.getOkButton().setText(LanguageBundle.getString(getOkKey()));

	if (includeApplyButton())
	{
		Button applyButton = new Button(LanguageBundle.getString("in_apply"));
		applyButton.setOnAction(evt -> applyButtonActionPerformed());
		ButtonBar.setButtonData(applyButton, ButtonBar.ButtonData.APPLY);
		buttonBar.getButtons().add(applyButton);
	}

	getContentPane().setLayout(new BorderLayout());
	getContentPane().add(getCenter(), BorderLayout.CENTER);
	getContentPane().add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
}
 
源代码20 项目: pcgen   文件: SinglePrefDialog.java
/**
 * Create a new modal SinglePrefDialog to display a particular panel.
 *  
 * @param parent The parent frame, used for positioning and to be modal 
 * @param prefsPanel The panel to be displayed.
 */
public SinglePrefDialog(JFrame parent, PCGenPrefsPanel prefsPanel)
{
	super(parent, prefsPanel.getTitle(), true);

	this.prefsPanel = prefsPanel;

	ButtonBar controlPanel = new OKCloseButtonBar(
			this::okButtonActionPerformed,
			this::cancelButtonActionPerformed
	);

	this.getContentPane().setLayout(new BorderLayout());
	this.getContentPane().add(prefsPanel, BorderLayout.CENTER);
	this.getContentPane().add(GuiUtility.wrapParentAsJFXPanel(controlPanel), BorderLayout.PAGE_END);
	prefsPanel.applyOptionValuesToControls();
	pack();
	Utility.installEscapeCloseOperation(this);
}
 
源代码21 项目: WorkbenchFX   文件: DialogControl.java
private Button createButton(ButtonType buttonType) {
  LOGGER.trace("Create Button: " + buttonType.getText());
  String buttonText;
  if (isButtonTextUppercase()) {
    buttonText = buttonType.getText().toUpperCase();
  } else {
    buttonText = buttonType.getText();
  }
  final Button button = new Button(buttonText);
  final ButtonBar.ButtonData buttonData = buttonType.getButtonData();
  ButtonBar.setButtonData(button, buttonData);
  button.setDefaultButton(buttonData.isDefaultButton());
  button.setCancelButton(buttonData.isCancelButton());
  return button;
}
 
源代码22 项目: DevToolBox   文件: MainAction.java
public void changeDubboVersion() {
    int idx = mc.dubboVersionBox.getSelectionModel().getSelectedIndex();
    saveSetting();
    Alert a = new Alert(Alert.AlertType.CONFIRMATION);
    if (idx > 1) {
        a.setContentText("其他dubbo请将dubbo的jar包放置在该工具lib目录下,并命名为dubbo.jar。放好之后重启工具即可!点击确认将关闭程序。");
    } else {
        a.setContentText("更换dubbo版本需要重启工具才能生效!点击确认将关闭程序。");
    }
    Optional<ButtonType> o = a.showAndWait();
    if (o.get().getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) {
        System.exit(0);
    }
}
 
源代码23 项目: DevToolBox   文件: MainAction.java
public void deleteRedisKeyAction() {
    ObservableList list = mc.redisValueTable.getSelectionModel().getSelectedItems();
    if (list.isEmpty()) {
        Toast.makeText("请选择要删除的记录").show(mc.pane.getScene().getWindow());
        return;
    }
    StringBuilder key = new StringBuilder();
    int i = 0;
    for (Object object : list) {
        Map mp = (Map) object;
        key.append(mp.get("key"));
        if (i != list.size() - 1) {
            key.append(",");
        }
        i++;
    }
    Alert a = new Alert(Alert.AlertType.CONFIRMATION);
    a.setTitle("确认删除");
    a.setContentText("确认要删除[" + key + "]这些键值吗?");
    a.initOwner(mc.pane.getScene().getWindow());
    Optional<ButtonType> o = a.showAndWait();
    if (o.get().getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) {
        String[] keys = key.toString().split(",");
        String name = (String) mc.redisDatabaseList.getSelectionModel().getSelectedItem();
        RedisUtil.deleteKeys(name, keys);
        Toast.makeText("删除成功", Duration.seconds(1)).show(mc.pane.getScene().getWindow());
        mc.paginationForValue.getPageFactory().call(0);
    }
}
 
源代码24 项目: phoebus   文件: ListSelectionDialog.java
public ListSelectionDialog(final Node root,
                           final String title,
                           final Supplier<ObservableList<String>>    available,
                           final Supplier<ObservableList<String>>    selected,
                           final Function<String, Boolean> addSelected,
                           final Function<String, Boolean> removeSelected)
{
    this.addSelected    = addSelected;
    this.removeSelected = removeSelected;

    selectedItems  = new ListView<>(selected.get());
    // We want to remove items from the available list as they're selected, and add them back as they are unselected.
    // Due to this we need a copy as available.get() returns an immutable list.
    availableItems = new ListView<>(
            FXCollections.observableArrayList(new ArrayList<>(available.get())));

    // Remove what's already selected from the available items
    for (String item : selectedItems.getItems())
        availableItems.getItems().remove(item);

    setTitle(title);
    
    final ButtonType apply = new ButtonType(Messages.Apply, ButtonBar.ButtonData.OK_DONE);

    getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, apply);
    getDialogPane().setContent(formatContent());

    setResizable(true);

    DialogHelper.positionAndSize(this, root,
            PhoebusPreferenceService.userNodeForClass(ListSelectionDialog.class),
            500, 600);

    setResultConverter(button ->  button == apply);
}
 
源代码25 项目: pcgen   文件: RadioChooserDialog.java
private void initComponents()
{
	Pane outerPane = new VBox();
	JFXPanel jfxPanel = new JFXPanel();
	jfxPanel.setLayout(new BorderLayout());

	setTitle(LanguageBundle.getString("in_chooserSelectOne")); //$NON-NLS-1$
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

	Node titleLabel = new Text(chooser.getName());
	titleLabel.getStyleClass().add("chooserTitle");
	URL applicationCss = getClass().getResource("/pcgen/gui3/application.css");
	String asString = applicationCss.toExternalForm();
	outerPane.getStylesheets().add(asString);
	outerPane.getChildren().add(titleLabel);
	toggleGroup = new ToggleGroup();

	outerPane.getChildren().add(buildButtonPanel());

	this.getContentPane().setLayout(new GridLayout());
	this.getContentPane().add(jfxPanel, BorderLayout.CENTER);


	ButtonBar buttonBar = new OKCloseButtonBar(
			this::onOK,
			this::onCancel);
	outerPane.getChildren().add(buttonBar);
	Platform.runLater(() -> {
		Scene scene = new Scene(outerPane);
		jfxPanel.setScene(scene);
		SwingUtilities.invokeLater(this::pack);
	});
}
 
源代码26 项目: pcgen   文件: RandomNameDialog.java
private void initUserInterface()
{
	getContentPane().setLayout(new BorderLayout());

	getContentPane().add(nameGenPanel, BorderLayout.CENTER);

	ButtonBar buttonBar = new OKCloseButtonBar(
			evt -> okButtonActionPerformed(),
			evt -> cancelButtonActionPerformed()
	);

	getContentPane().add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
}
 
源代码27 项目: pcgen   文件: SpellChoiceDialog.java
private void initComponents()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());

	pane.add(spellChoicePanel, BorderLayout.CENTER);

	ButtonBar buttonBar = new OKCloseButtonBar(
			this::onOK,
			this::onCancel
	);

	pane.add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END);
}
 
源代码28 项目: phoenicis   文件: AddRepositoryDialog.java
/**
 * Constructor
 */
public AddRepositoryDialog() {
    super();

    this.setResizable(true);
    this.setTitle(tr("Add a new Repository"));

    this.chooseRepositoryTypePanel = new ChooseRepositoryTypePanel();
    this.chooseRepositoryTypePanel.setOnRepositoryTypeSelection(repositoryType -> {
        this.repositoryDetailsPanel = repositoryType.getRepositoryDetailsPanel();

        this.setHeaderText(repositoryDetailsPanel.getHeader());
        this.getDialogPane().setContent(repositoryDetailsPanel);
        this.getDialogPane().getButtonTypes().setAll(ButtonType.FINISH, ButtonType.CANCEL);
    });

    this.setHeaderText(chooseRepositoryTypePanel.getHeader());

    this.setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.FINISH && repositoryDetailsPanel != null) {
            return repositoryDetailsPanel.createRepositoryLocation();
        }
        return null;
    });

    this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL);
    this.getDialogPane().setContent(chooseRepositoryTypePanel);
    this.getDialogPane().setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
}
 
源代码29 项目: archivo   文件: Archivo.java
public boolean showErrorMessageWithAction(String header, String message, String action,
                                          EventHandler<ActionEvent> eventHandler) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Something went wrong...");
    alert.setHeaderText(header);

    VBox contentPane = new VBox();
    HyperlinkLabel contentText = new HyperlinkLabel(message);
    contentText.setPrefWidth(500);
    contentPane.setPadding(new Insets(30, 15, 20, 15));
    contentPane.getChildren().add(contentText);
    alert.getDialogPane().setContent(contentPane);

    if (eventHandler != null) {
        contentText.setOnAction(eventHandler);
        contentText.addEventHandler(ActionEvent.ACTION, (event) -> alert.close());
    }

    ButtonType closeButtonType = new ButtonType("Close", ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType actionButtonType = new ButtonType(action, ButtonBar.ButtonData.YES);
    ButtonType reportButtonType = new ButtonType("Report Problem", ButtonBar.ButtonData.HELP_2);
    alert.getButtonTypes().setAll(closeButtonType, reportButtonType);
    if (action != null) {
        alert.getButtonTypes().add(actionButtonType);
        ((Button) alert.getDialogPane().lookupButton(closeButtonType)).setDefaultButton(false);
        ((Button) alert.getDialogPane().lookupButton(reportButtonType)).setDefaultButton(false);
        ((Button) alert.getDialogPane().lookupButton(actionButtonType)).setDefaultButton(true);
    }

    Optional<ButtonType> result = alert.showAndWait();
    while (result.isPresent() && result.get() == reportButtonType) {
        rootController.reportProblem(null);
        result = alert.showAndWait();
    }
    return (result.isPresent() && result.get() == actionButtonType);
}
 
源代码30 项目: pcgen   文件: RadioChooserDialog.java
private void initComponents()
{
	Pane outerPane = new VBox();
	JFXPanel jfxPanel = new JFXPanel();
	jfxPanel.setLayout(new BorderLayout());

	setTitle(LanguageBundle.getString("in_chooserSelectOne")); //$NON-NLS-1$
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

	Node titleLabel = new Text(chooser.getName());
	titleLabel.getStyleClass().add("chooserTitle");
	URL applicationCss = getClass().getResource("/pcgen/gui3/application.css");
	String asString = applicationCss.toExternalForm();
	outerPane.getStylesheets().add(asString);
	outerPane.getChildren().add(titleLabel);
	toggleGroup = new ToggleGroup();

	outerPane.getChildren().add(buildButtonPanel());

	this.getContentPane().setLayout(new GridLayout());
	this.getContentPane().add(jfxPanel, BorderLayout.CENTER);


	ButtonBar buttonBar = new OKCloseButtonBar(
			this::onOK,
			this::onCancel);
	outerPane.getChildren().add(buttonBar);
	Platform.runLater(() -> {
		Scene scene = new Scene(outerPane);
		jfxPanel.setScene(scene);
		SwingUtilities.invokeLater(this::pack);
	});
}
 
 类所在包
 类方法
 同包方法