/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ package textareaevents; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextArea; import javafx.scene.input.MouseEvent; import javafx.scene.layout.StackPane; import javafx.stage.Stage; /** * * @author asakharu */ public class TextAreaEvents extends Application { @Override public void start(Stage primaryStage) { TextArea ta = new TextArea("Text area"); ta.setOnMouseDragged(new EventHandler() { @Override public void handle(MouseEvent t) { System.out.println("Mouse draged"); } }); ta.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent t) { System.out.println("Mouse pressed"); } }); ta.setOnMouseReleased(new EventHandler() { @Override public void handle(MouseEvent t) { System.out.println("Mouse released"); } }); StackPane root = new StackPane(); root.getChildren().add(ta); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } /** * The main() method is ignored in correctly deployed JavaFX application. * main() serves only as fallback in case the application can not be * launched through deployment artifacts, e.g., in IDEs with limited FX * support. NetBeans ignores main(). * * @param args the command line arguments */ public static void main(String[] args) { launch(args); } }