# JavaFX GIF Player

**URL:** <https://discourse.processing.org/t/javafx-gif-player/46543>\
**Category:** Gallery\
**Created:** [June 14, 2025, 12:20am UTC](https://discourse.processing.org/t/javafx-gif-player/46543 "2025-06-14T00:20:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [June 14, 2025, 12:20am UTC](https://discourse.processing.org/t/javafx-gif-player/46543/1 "2025-06-14T00:20:32Z")

</div>

The following code will create a JavaFX ImageView in the default Processing window and may be used as a .gif player in addition to displaying other images. You will need the full url for the file, in this case in the sketch folder (change posted code to reflect your system and filename).  
`Disclaimer: This demo will not run 'asis' on the Windows or Linux operating systems. It will be necessary to create a separate folder entitled 'code' in the sketch folder and copy/paste the seven JavaFX modules into it. These modules are located in the Processing/libraries/javafx/library/yourOS/modules folder. It may also be necessary to add the line 'import processing.javafx.*;' to the top of the sketch.`

```auto
import javafx.scene.canvas.Canvas;
import javafx.scene.layout.StackPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.io.FileInputStream;

StackPane root;
FileInputStream input;

void setup() {
  size(400, 400, FX2D);
  surface.setTitle("JavaFX GIF Player");
  Canvas canvas = (Canvas)surface.getNative();
  root = (StackPane)canvas.getParent();
  try {
    input = new FileInputStream("/Users/yourName/Documents/Processing/yourSketchName/yourFile.gif");
  }
  catch(IOException e) {
    println("Unable to input file.",e);
  }
  Image image = new Image(input);
  ImageView imageView = new ImageView(image);
  root.getChildren().add(imageView);
}

```

**Output:**

 ![gp](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/1/217637ea25614e0691522cb20ca8100b7f0c9e43.jpeg)
