Example usage for javafx.scene.control Button addEventFilter

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

Introduction

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

Prototype

public final <T extends Event> void addEventFilter(final EventType<T> eventType,
        final EventHandler<? super T> eventFilter) 

Source Link

Document

Registers an event filter to this node.

Usage

From source file:io.github.mzmine.util.jfreechart.ManualZoomDialog.java

/**
 * Constructor//from   w w  w. j  av  a2  s .c  om
 */
public ManualZoomDialog(Window parent, XYPlot plot) {

    initOwner(parent);

    setTitle("Manual zoom");

    setGraphic(new ImageView("file:icons/axesicon.png"));

    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    xAxis = (NumberAxis) plot.getDomainAxis();
    yAxis = (NumberAxis) plot.getRangeAxis();

    try {
        URL layersDialogFXML = getClass().getResource(DIALOG_FXML);
        FXMLLoader loader = new FXMLLoader(layersDialogFXML);
        loader.setController(this);
        GridPane grid = loader.load();
        getDialogPane().setContent(grid);
    } catch (Exception e) {
        e.printStackTrace();
    }

    final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK);
    btOk.addEventFilter(ActionEvent.ACTION, event -> {
        commitChanges(event);
    });

}