本文整理匯總了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);
}