In the previous recipe, Accessing remote data with HttpRequest, we saw how to use the HttpRequest
class to request and receive textual data from a remote server. How about the next most popular resources on the web: Images? The answer is a resounding yes. In this recipe, we will see how to pull down image binary data from the server specifically and display it in your JavaFX application.
In Chapter 5, JavaFX Media, we learned how to use the Image API to download images automatically. However, the API offers little control over the download process. In this recipe, we are going to use HttpRequest
, which provides granular control over the content of the image downloaded. For some portions of the code, you will need to be familiar with the use of JavaFX data binding and triggers (see Chapter 1, Getting Started with JavaFX for details). For a background on how to display images in JavaFX, review the recipe Loading and displaying images with...