package javaapplication13; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class JavaApplication13 extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { TextField lv = new TextField(); final Button b = new Button("Button"); b.setDefaultButton(true); b.setOnAction(new EventHandler() { @Override public void handle(ActionEvent t) { System.out.println("Fire!"); b.setDefaultButton(false); } }); stage.setScene(new Scene(new VBox(lv, b))); stage.show(); } }