2-1. Creating Images

Problem

There are photos in your file directory that you would like to quickly browse through and showcase.

Solution

Create a simple JavaFX image viewer application. The main Java classes used in this recipe are:

  • javafx.scene.image.Image
  • javafx.scene.image.ImageView
  • EventHandler<DragEvent> classes

The following source code is an implementation of an image viewer application:

package javafx2introbyexample.chapter2.recipe2_01; import java.io.File; import java.util.ArrayList; import java.util.List; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.DragEvent; ...

Get JavaFX 2.0: Introduction by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.