title: Set an Image as a Node to create a Path Transition JAVA/JAVAFX
body: <pre><code>package application;
  import javafx.animation.PathTransition;
  import javafx.animation.Timeline;
  import javafx.application.Application;
  import javafx.scene.Group;
  import javafx.scene.Node;
  import javafx.scene.Scene;
  import javafx.scene.image.Image;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Circle;
  import javafx.scene.shape.CubicCurveTo;
  import javafx.scene.shape.MoveTo;
  import javafx.scene.shape.Path;
  import javafx.stage.Stage;
  import javafx.util.Duration;
  //from www  . j a va 2 s  .  c  o  m
  public class Experiment3 extends Application {
  
    @Override
    public void start(final Stage stage) throws Exception {
      final Group group = new Group();
      final Scene scene = new Scene(group, 600, 400, Color.GHOSTWHITE);
      stage.setScene(scene);
      stage.setTitle(&quot;JavaFX 2 Animations&quot;);
      stage.show();
      final Circle circle = new Circle(20, 20, 15);
      circle.setFill(Color.DARKRED);
      final Image i1 = new Image(getClass().getResourceAsStream(&quot;IMG_Strength/Abs1.png&quot;),400,400,false,false);
  
      final Path path = new Path();
      path.getElements().add(new MoveTo(20, 20));
      path.getElements().add(new CubicCurveTo(30, 10, 380, 120, 200, 120));
      path.getElements().add(new CubicCurveTo(200, 1120, 110, 240, 380, 240));
      path.setOpacity(0.5);
  
      group.getChildren().add(path);
      group.getChildren().add(i1);
      final PathTransition pathTransition = new PathTransition();
  
      pathTransition.setDuration(Duration.seconds(8.0));
      pathTransition.setDelay(Duration.seconds(.5));
      pathTransition.setPath(path);
      pathTransition.setNode(circle);
      pathTransition
          .setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
      pathTransition.setCycleCount(Timeline.INDEFINITE);
      pathTransition.setAutoReverse(true);
      pathTransition.play();
    }
  
    public static void main(final String[] arguments) {
      Application.launch(arguments);
    }
  </code></pre>
  <p>}</p>
  <p>It returns an error at final Image because it is not a Node. So my qu is how can I make the image a node in order to add it to group.getChildren.add(i1)
  My purpose is to make the image moving in a rectangular path</p>