Java Reference
In-Depth Information
8
“But theater, because of its nature, both text, images, multimedia effects, has a
wider base of communication with an audience. That's why I call it the most
social of the various art forms.”
—Wole Soyinka
Multimedia is the application of multiple means to present content. Convention-
ally, the media components include text, interactive controls, special effects, pic-
tures, animation, audio, and video. We have already covered text and interactive
controls in Chapter 5, Create User Interfaces; special effects in Chapter 6, Apply
Special Effects; and animation in Chapter 7, Add Motion with JavaFX Anima-
tion. In this chapter, we will focus on images, sound, and video.
Loading and displaying images in JavaFX is quite simple. First, you create an
Image
object,
javafx.scene.image.Image
, and then you create an
ImageView
,
javafx.scene.image.ImageView
, to show the image on the display.
Minimally, you can create an
Image
object by just supplying a URL to the loca-
tion of the image. The URL may be local, beginning with a
file
: protocol, or
remote, using an Internet protocol like
http
:. For example, to load an image
from the directory of the current script file, in the figures subdirectory, you
would use the built-in
__DIR__
variable.
var image = Image {
url: "{__DIR__}figures/myImage.gif"
}
219
Search WWH ::
Custom Search