import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class AnimatedGifDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        stage.setScene(createScene());
        stage.setTitle("Animated GIF Demo");
        stage.setWidth(800);
        stage.setHeight(600);
        stage.setOnCloseRequest(event -> Platform.exit());
        stage.show();
    }

    private Scene createScene() {
        Image image = new Image(getClass().getResource("sample.gif").toString());
        if (image.isError()) {
            image.getException().printStackTrace();
        }
        ImageView imageView = new ImageView(image);
        BorderPane borderPane = new BorderPane(imageView);
        return new Scene(borderPane);
    }
} 