/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test.scenegraph.app; import javafx.animation.FadeTransitionBuilder; import javafx.animation.ParallelTransitionBuilder; import javafx.animation.PathTransition; import javafx.animation.PauseTransition; import javafx.animation.SequentialTransition; import javafx.animation.Timeline; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Rectangle2D; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; import javafx.scene.input.DataFormat; import javafx.scene.input.MouseEvent; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.CubicCurveTo; import javafx.scene.shape.LineTo; import javafx.scene.shape.MoveTo; import javafx.scene.shape.Path; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import javafx.util.Duration; public class TmpApp extends Application{ public static void main(String[] args) { launch(args); } protected int click = 0; public static final String IMAGE_BASE = "/test/scenegraph/resources/"; public static final String defaultImagePath = IMAGE_BASE + "car.png"; public static final String defaultImagePath2 = IMAGE_BASE + "java_expert.png"; @Override public void start(Stage primaryStage) { primaryStage.setTitle("Image Viewport Test!"); Group root = new Group(); Scene scene = new Scene(root, 300, 300); //ImageView image = new ImageView(new Image("http://bitendian.com/img/icons/all/64/java_expert.png")); ImageView image = new ImageView(new Image(getClass().getResourceAsStream(defaultImagePath2))); image.setViewport(new Rectangle2D(30, 30, 340, 340)); image.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("Click on image: "+event.getButton()+" -- "+click); click ++; } }); root.getChildren().add(image); primaryStage.setScene(scene); primaryStage.show(); } }