Java Code Examples for javafx.scene.control.ButtonBar#setButtonData()

The following examples show how to use javafx.scene.control.ButtonBar#setButtonData() . 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: 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 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: DialogControl.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: WidgetColorPopOverController.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private void updateButton ( final Button button, final ButtonType buttonType ) {
    button.setText(buttonType.getText());
    ButtonBar.setButtonData(button, buttonType.getButtonData());
    button.setDefaultButton(buttonType.getButtonData().isDefaultButton());
    button.setCancelButton(buttonType.getButtonData().isCancelButton());
}
 
Example 5
Source File: WidgetFontPopOverController.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private void updateButton ( final Button button, final ButtonType buttonType ) {
    button.setText(buttonType.getText());
    ButtonBar.setButtonData(button, buttonType.getButtonData());
    button.setDefaultButton(buttonType.getButtonData().isDefaultButton());
    button.setCancelButton(buttonType.getButtonData().isCancelButton());
}
 
Example 6
Source File: SliderConfigPopOver.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
SliderConfigPopOver(final WidgetProperty<Double> increment_property)
{
    this.increment_property = increment_property;
    final GridPane content = new GridPane();
    // content.setGridLinesVisible(true); // Debug layout
    content.setHgap(5);
    content.setVgap(5);
    content.add(new Label("Configure"), 0, 0, 2, 1);
    content.add(new Label("Increment:"), 0, 1);
    content.add(config_increment, 1, 1);

    final ButtonBar buttons = new ButtonBar();
    final Button ok = new Button(ButtonType.OK.getText());
    ButtonBar.setButtonData(ok, ButtonType.OK.getButtonData());
    ok.setOnAction(event ->
    {
        try
        {
            increment_property.setValue(Double.parseDouble(config_increment.getText().trim()));
            hide();
        }
        catch (NumberFormatException ex)
        {
            // Update text, don't close
            config_increment.setText(Double.toString(increment_property.getValue()));
        }
    });

    final Button cancel = new Button(ButtonType.CANCEL.getText());
    ButtonBar.setButtonData(cancel, ButtonType.CANCEL.getButtonData());
    cancel.setOnAction(event -> hide());

    buttons.getButtons().addAll(ok, cancel);
    content.add(buttons, 0, 2, 2, 1);

    // OK button is the 'default' button
    content.addEventFilter(KeyEvent.KEY_PRESSED, event ->
    {
        if (event.getCode() == KeyCode.ENTER)
            ok.getOnAction().handle(null);
    });

    setContent(content);
}
 
Example 7
Source File: FontButton.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private Node createContent()
{
    // Name:  combo
    // Size:  combo
    // Style: [x] Bold [x] Italic
    //            [OK]   [Cancel]

    final GridPane layout = new GridPane();
    layout.setPadding(new Insets(5));
    layout.setHgap(5);
    layout.setVgap(5);

    layout.add(new Label(Messages.FontBtnName), 0, 0);
    layout.add(families, 1, 0, 2, 1);

    layout.add(new Label(Messages.FontBtnSize), 0, 1);
    layout.add(size, 1, 1);

    layout.add(new Label(Messages.FontBtnStyle), 0, 2);
    layout.add(bold, 1, 2);
    layout.add(italic, 2, 2);

    example.setPrefSize(200, 50);
    layout.add(example, 0, 3, 3, 1);

    final ButtonBar buttons = new ButtonBar();
    final Button ok = new Button(ButtonType.OK.getText());
    ButtonBar.setButtonData(ok, ButtonType.OK.getButtonData());
    final Button cancel = new Button(ButtonType.CANCEL.getText());
    ButtonBar.setButtonData(cancel, ButtonType.CANCEL.getButtonData());
    buttons.getButtons().addAll(ok, cancel);
    layout.add(buttons, 0, 4, 4, 1);

    JobManager.schedule(Messages.FontBtnJobName, this::getFamilies);

    size.setEditable(true);
    families.valueProperty().addListener(event -> updateFont());
    size.setOnAction(event -> updateFont());
    bold.setOnAction(event -> updateFont());
    italic.setOnAction(event -> updateFont());
    ok.setOnAction(event ->
    {
        popover.hide();
        setText(getDescription(font));
        on_font_selected.accept(font);
    });
    cancel.setOnAction(event -> popover.hide());

    return layout;
}