O'Reilly logo

JavaFX 2.0: Introduction by Example by Carl Dea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required