/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package fxsqe; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.ButtonBuilder; import javafx.scene.layout.HBox; import javafx.stage.Stage; /** * * @author javafx */ public class TestButtons extends Application { public static void main(String[] args) { launch(); } @Override public void start(Stage stage) throws Exception { HBox root; stage.setScene(new Scene(root = new HBox(), 300, 300)); for (int i = 0; i < 5; i++) { final int ii = i; root.getChildren().add( ButtonBuilder.create().text("press").onAction(new EventHandler() { @Override public void handle(ActionEvent t) { System.out.println("pressed " + ii); } }).build()); } stage.show(); } }