Example usage for javafx.scene.control Button setCancelButton

List of usage examples for javafx.scene.control Button setCancelButton

Introduction

In this page you can find the example usage for javafx.scene.control Button setCancelButton.

Prototype

public final void setCancelButton(boolean value) 

Source Link

Usage

From source file:eu.ggnet.dwoss.util.OkCancelStage.java

public OkCancelStage(String title, T payload) {
    this.payload = payload;
    BorderPane pane = new BorderPane();
    pane.setCenter(payload);/*from  w  ww.j a  v a 2  s  .c om*/

    Button okButton = new Button("Ok");
    okButton.defaultButtonProperty();

    Button cancelButton = new Button("Abbrechen");
    cancelButton.setCancelButton(true);

    HBox bottom = new HBox();
    bottom.setPadding(new Insets(10));
    bottom.getChildren().addAll(okButton, cancelButton);
    pane.setBottom(bottom);
    if (!StringUtils.isBlank(title))
        setTitle(title);
    setScene(new Scene(pane));

    okButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            OkCancelStage.this.ok = true;
            close();
        }
    });
    cancelButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            close();
        }
    });
}

From source file:cz.lbenda.gui.tableView.FilterMenuItem.java

private void prepareOkCancelBar() {
    Button okButton = new Button(msgOK);
    okButton.setDefaultButton(true);//from   w  ww.j  ava2 s  .c  o  m
    Button cancelButton = new Button(msgCancel);
    cancelButton.setCancelButton(true);
    okCancelBar.getChildren().addAll(okButton, cancelButton);

    //noinspection unchecked
    final StringConverter converter = filterableTableView.stringConverter(tableColumn);
    okButton.setOnAction(event -> {
        if (filter != null) {
            filterableTableView.filters().remove(filter);
        }
        if (!isFilter()) {
            tableColumn.removeLeftIndicator(filterIndicator);
        } else {
            tableColumn.addLeftIndicator(filterIndicator);
            //noinspection unchecked
            filter = row -> {
                //noinspection unchecked
                Object value = filterableTableView.valueForColumn(row, tableColumn);
                String text;
                if (value == null) {
                    text = "";
                } else { //noinspection unchecked
                    text = converter.toString(value);
                }
                return chosenItemNames.contains(text);
            };
            //noinspection unchecked
            filterableTableView.filters().add(filter);
        }
    });
}