Skip to content

Instantly share code, notes, and snippets.

@TheItachiUchiha
Last active October 11, 2015 13:58
Show Gist options
  • Save TheItachiUchiha/5209f82b6d9f31c97b57 to your computer and use it in GitHub Desktop.
Save TheItachiUchiha/5209f82b6d9f31c97b57 to your computer and use it in GitHub Desktop.
Clickable
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Button button1 = new Button("Hey");
VBox box = new VBox(10, button1);
button1.setOnAction(event -> {
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(event1 -> System.out.println("Hello World!"));
box.getChildren().add(btn);
});
box.setAlignment(Pos.CENTER);
Scene scene = new Scene(box, 200, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment