JavaFX 2.0 Introduction by Example book
Join the DZone community and get the full member experience.Join For Free
i recently finished writing a book on the new release of the javafx 2.0 sdk and it has already been placed on the shelves at a bookstore ( amazon ) near you. the book will walk you through, step-by-step, giving you the ins and outs of javafx 2.0. when you encounter a chapter you will be presented recipes which will pose a problem (use case scenario) that will have an associated solution. after a proposed solution you will be shown an example source code listing and its display output after the program has been executed. lastly you will be shown a section called “how it works” which will explain and discuss the examples and their details. to see more about this book, such as the source code and errata, please visit apress publishing ( http://www.apress.com/9781430242574 ).
in this blog entry i also want to give you a sneak preview of a java webstart example of chapter 3 recipe 3-1 (javafx 2.0 mp3 player). to launch the javafx mp3 player just jump down to chapter 3 below.
below is a brief overview of the chapters in the book:
chapter 1: javafx fundamentals
i begin by instructing you on how to get your environment set-up to rapidly develop rich internet applications using java and javafx.
after reading this chapter you will be able to answer questions such as:
- how do i create gui applications?
- what is the scene graph?
- how do i display text onto the scene graph?
- how do i incorporate ui controls into my application?
- how do i bind expressions?
- how do i draw shapes?
- how do i generate a background process?
- how do i associate keyboard sequences to applications?
chapter 2: graphics with javafx
in chapter 2 there are recipe examples which delve into javafx’s graphics and animation capabilities. i begin by explaining some of the basics of javafx’s graphics such as rendering images and animating nodes. i then go on to more advanced topics such as animating with transitions, manipulating layouts, and enhancing nodes using javafx css.
the following picture, taken from recipe 2-2, depicts an image viewer application with a custom news ticker control at the bottom.
chapter 3: media with javafx
chapter 3 covers all things media related. here i reveal javafx’s media apis which allows you to integrate audio and video into your applications. i begin by showing you how to create a javafx mp3 player and a video player. then i will walk you through the different ways to enhance the video player with additional features to control media actions and events, mark positions in a video, and synchronize animations.
the illustration below, taken from recipe 3-1, depicts a javafx 2.0 mp3 player with a graphical visualization (using the audiospectrumlistener api). before launching the example you will need to know the requirements and instructions to run the demo example.
simple requirements and instructions to run the javafx 2.0 mp3 player:
- java 6 update 24 jre or greater (java 7 is preferred)
- javafx 2.0 or greater (javafx 2.0.2 is preferred)
- windows xp sp 3 or greater. (i will update the jnlp as javafx becomes available on other oses)
- click the webstart launch button below.
- by using your file explorer on your host operating system “drag and drop” a music mp3 file onto the surface of the application.
- use the controls to the bottom right of the application to pause, play, and stop the music.
- you may use your mouse to drag the application around your desktop.
- to close the application click on the ‘x’ in the upper right hand corner.
to launch the application click on the java webstart button below:
chapter 4: javafx on the web
in chapter 4 you will be able to take advantage of the interoperability between javafx and html5.
for starters i will cover how to embed javafx applications into a web page. i then will demonstrate javafx’s powerful webview and webengine apis. below are the recipe examples from chapter 4 which utilize the webview and webengine apis:
- displaying html5 content (animated analog clock application)
- loading data from a web service (weather application)
- handling web events
- storing and displaying data using an embedded database (rss reader application)
depicted below is an animated analog clock application, taken from recipe 4-2, demonstrating the ability to render html5 content.
i assume you know the java programming language and some web development concepts. i hope you will enjoy these examples which can be used freely in your own projects. i’ve tested the examples with the latest java 7 update 2 and javafx 2.0.2 runtime and sdk. if you have any questions or comments feel free to ask them here or on my twitter account @carldea .
Opinions expressed by DZone contributors are their own.