4-2. Displaying HTML5 Content
Problem
You are so engrossed with a project for work that you often miss your kid’s soccer games. What you need is a clock application to keep track of the time.
Solution
Create a JavaFX based-application containing an analog clock that was created as HTML5 content. Use JavaFX’s WebView
API to render HTML5 content in your application.
The following source code is a JavaFX application displaying an animated analog clock. The application will load an SVG file named clock3.svg
and display the contents onto the JavaFX Scene graph:
package javafx2introbyexample.chapter4.recipe4_02;
import java.net.URL;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.paint.Color; import javafx.scene.web.WebView; ...
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.