/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package main; import javafx.application.Application; import javafx.event.EventHandler; import javafx.geometry.VPos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; public class JavaFxApplication extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(JavaFxApplication.class, args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World"); Group root = new Group(); Scene scene = new Scene(root, 250, 80); Text text1 = new Text("Text"); text1.setFont(new Font(48)); text1.setTextOrigin(VPos.TOP); text1.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("Click on Text: "+event.getButton()); } }); root.getChildren().add(text1); primaryStage.setScene(scene); primaryStage.setVisible(true); } }