本文整理汇总了Java中javafx.scene.control.ButtonBar.setButtonData方法的典型用法代码示例。如果您正苦于以下问题:Java ButtonBar.setButtonData方法的具体用法?Java ButtonBar.setButtonData怎么用?Java ButtonBar.setButtonData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ButtonBar
的用法示例。
在下文中一共展示了ButtonBar.setButtonData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeBottomButtons
import javafx.scene.control.ButtonBar; //导入方法依赖的package包/类
/**
* Initializes "OK" and "Cancel" buttons.
*/
private void initializeBottomButtons() {
Button okButton = new Button("OK");
ButtonBar.setButtonData(okButton, ButtonData.OK_DONE);
Button cancelButton = new Button("Cancel");
ButtonBar.setButtonData(cancelButton, ButtonData.CANCEL_CLOSE);
buttonBar.getButtons().addAll(okButton, cancelButton);
okButton.addEventFilter(ActionEvent.ACTION, (event) -> {
applySettings();
((Stage) okButton.getScene().getWindow()).close();
});
cancelButton.addEventFilter(ActionEvent.ACTION, (event) -> {
((Stage) okButton.getScene().getWindow()).close();
});
validationSupport.validationResultProperty().addListener((o, oldVal, newVal) -> {
if (newVal.getErrors().isEmpty()) {
// If no errors, enable okButton.
okButton.setDisable(false);
} else {
// If errors, disable okButton.
okButton.setDisable(true);
}
});
}
示例2: createButton
import javafx.scene.control.ButtonBar; //导入方法依赖的package包/类
private static Button createButton(final ButtonType type)
{
final Button button = new Button(type.getText());
ButtonBar.setButtonData(button, type.getButtonData());
button.setDefaultButton(type.getButtonData().isDefaultButton());
button.setCancelButton(type.getButtonData().isCancelButton());
return button;
}
示例3: updateButton
import javafx.scene.control.ButtonBar; //导入方法依赖的package包/类
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());
}
示例4: SliderConfigPopOver
import javafx.scene.control.ButtonBar; //导入方法依赖的package包/类
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);
}