javafx.scene.control.ButtonBar Java Examples

The following examples show how to use javafx.scene.control.ButtonBar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoardNameDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
    });

}
 
Example #2
Source File: AbstractDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
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);
}
 
Example #3
Source File: EquipCustomizerDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
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);
}
 
Example #4
Source File: FXMLTimingLocationInputController.java    From pikatimer with GNU General Public License v3.0 6 votes vote down vote up
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(); 
    }
}
 
Example #5
Source File: FXMLTimingLocationInputController.java    From pikatimer with GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #6
Source File: SinglePrefDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: DialogFactory.java    From Motion_Profile_Generator with MIT License 6 votes vote down vote up
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;
}
 
Example #8
Source File: DialogFactory.java    From Motion_Profile_Generator with MIT License 6 votes vote down vote up
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;
}
 
Example #9
Source File: Archivo.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #10
Source File: Archivo.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: Archivo.java    From archivo with GNU General Public License v3.0 6 votes vote down vote up
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);
    }
}
 
Example #12
Source File: DialogMessage.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #13
Source File: EquipCustomizerDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
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);
}
 
Example #14
Source File: Document.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
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;
    }
 
Example #15
Source File: UIUtils.java    From img2latex-mathpix with Apache License 2.0 6 votes vote down vote up
/**
 * 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();

}
 
Example #16
Source File: DialogSkin.java    From WorkbenchFX with Apache License 2.0 6 votes vote down vote up
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");
}
 
Example #17
Source File: SinglePrefDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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);
}
 
Example #18
Source File: AbstractDialog.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
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);
}
 
Example #19
Source File: ModalDialog.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #20
Source File: DialogMessage.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #21
Source File: RadioChooserDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
	});
}
 
Example #22
Source File: RandomNameDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
}
 
Example #23
Source File: SpellChoiceDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
}
 
Example #24
Source File: AddRepositoryDialog.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #25
Source File: Archivo.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #26
Source File: PasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
public PasswordInputDialog() {
    super();
    pass = new PasswordField();
    grid = new GridPane();
    heading = new Label();

    heading.getStyleClass().add("label-heading");
    contentTextProperty().addListener((observable, oldVal, newVal) -> {
        heading.setText(newVal);
    });

    grid.setHgap(MainController.DIALOG_HGAP);
    grid.setVgap(MainController.DIALOG_VGAP);
    grid.addRow(0, heading, pass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(pass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            return pass.getText();
        }
        return null;
    });
}
 
Example #27
Source File: SpellChoiceDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
}
 
Example #28
Source File: DualPasswordInputDialog.java    From cate with MIT License 5 votes vote down vote up
public DualPasswordInputDialog(final ResourceBundle resources) {
    super();

    newLabel = new Label(resources.getString("dialogEncrypt.passNew"));
    repeatLabel = new Label(resources.getString("dialogEncrypt.passRepeat"));
    newPass = new PasswordField();
    repeatPass = new PasswordField();

    newLabel.getStyleClass().add("label-heading");
    repeatLabel.getStyleClass().add("label-heading");

    grid = new GridPane();
    grid.setHgap(DIALOG_HGAP);
    grid.setVgap(DIALOG_VGAP);
    grid.addRow(0, newLabel, newPass);
    grid.addRow(1, repeatLabel, repeatPass);

    getDialogPane().getStylesheets().add(CATE.DEFAULT_STYLESHEET);
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(grid);

    Platform.runLater(newPass::requestFocus);

    setResultConverter(dialogButton -> {
        if (dialogButton.getButtonData() == ButtonBar.ButtonData.OK_DONE) {
            if (!newPass.getText().trim().isEmpty() && !repeatPass.getText().trim().isEmpty()) {
                if (Objects.equals(newPass.getText(), repeatPass.getText())) {
                    return newPass.getText();
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
        return null;
    });
}
 
Example #29
Source File: RandomNameDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
}
 
Example #30
Source File: RadioChooserDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
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);
	});
}