Java examples for JavaFX:Introduction
Creating a Simple User Interface in JavaFX
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.scene.Group; public class Main extends Application { final Group root = new Group(); public static void main(String[] args) { Application.launch(args);//from w w w . j ava 2 s .co m } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World"); Scene scene = new Scene(root, 300, 250); Button btn = new Button(); btn.setLayoutX(100); btn.setLayoutY(80); btn.setText("Hello World"); btn.setOnAction((event) -> { System.out.println("Hello World"); }); root.getChildren().add(btn); primaryStage.setScene(scene); primaryStage.show(); } }