import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class Main extends Application { //Calls launch in superclass //This sets up program as JavaFX application then calls start() public static void main(String[] args) { launch(args); } //Every JavaFX program needs this method //Only parameter is stage (the main window) @Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World!"); Button btn = new Button(); btn.setText("Hey baby"); /* When button is clicked, an action occurs btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); */ //A layout pane is how you want everything to be positioned and displayed //Will make a lot more sense when we have more than one item StackPane layout = new StackPane(); layout.getChildren().add(btn); //Add a scene to the stage (content to the window) Scene scene = new Scene(layout, 300, 250); primaryStage.setScene(scene); primaryStage.show(); } }