Introduction

Welcome to JavaFX 8: Introduction by Example.

What is JavaFX?

JavaFX is Java’s next-generation graphical user interface (GUI) toolkit that allows developers to rapidly build rich cross-platform applications. Built from the ground up, JavaFX takes advantage of modern GPUs through hardware-accelerated graphics while providing well-designed programming interfaces enabling developers to combine graphics, animation, and UI controls. The new JavaFX 8 is a pure Java language application programming interface (API). The goal of JavaFX is to be used across many types of devices, such as embedded devices, smartphones, TVs, tablet computers, and desktops.

Nandini Ramani of Oracle plainly states the intended direction of JavaFX as a platform in the following excerpt from the screencast Introducing JavaFX:

The industry is moving toward multi-core/multi-threading platforms with GPUs. JavaFX leverages these attributes to improve execution efficiency and UI design flexibility. Our initial goal is to give architects and developers of enterprise applications a set of tools and APIs to help them build better data-driven business applications.

—Nandini Ramani
Oracle Corp.
VP of Development, Java Client Platform

Before the creation of JavaFX, the development of rich client-side applications involved the gathering of many separate libraries and APIs to achieve highly functional applications. These separate libraries include media, UI controls, Web, 3D, and 2D APIs. Because integrating these APIs together can be rather difficult, the talented engineers at Oracle created a new set of JavaFX libraries that roll up all the same capabilities under one roof. JavaFX is the Swiss Army Knife of GUI toolkits. JavaFX 8 is a pure Java (language) API that allows developers to leverage existing Java libraries and tools.

9781430264606_FM-01.jpg

Figure FM-1. JavaFX

Depending on who you talk to, you are likely to encounter different definitions of “user experience” (or in the UI world, UX). But one fact remains; the users will always demand better content and increased usability from GUI applications. In light of this fact, developers and designers often work together to craft applications to fulfill this demand. JavaFX provides a toolkit that helps both the developer and designer (in some cases, the same person) to create functional yet aesthetically pleasing applications. Another thing to acknowledge is that if you are developing a game, media player, or the usual enterprise application, JavaFX will not only assist in developing richer UIs, but you’ll also find that the APIs are extremely well designed to greatly improve developer productivity (we’re all about the user of the API’s perspective).

Although this book doesn’t go through an exhaustive study of all of JavaFX 8’s capabilities, you will find common use cases that can help you build richer applications. Hopefully, this book will lead you in the right direction by providing practical, real-world examples.

Some History

In 2005 Sun Microsystems acquired the company SeeBeyond, where a software engineer named Chris Oliver created a graphics-rich scripting language known as F3 (Form Follows Function). F3 was later unveiled by Sun Microsystems at the 2007 JavaOne conference as JavaFX. On April 20, 2009, Oracle Corporation announced the acquisition of Sun Microsystems, making Oracle the new steward of JavaFX.

At JavaOne 2010, Oracle announced the JavaFX roadmap, which included its plans to phase out the JavaFX scripting language and re-create the JavaFX platform for the Java platform as Java-based APIs. As promised based on the 2010 roadmap, JavaFX 2.0 SDK was released at JavaOne, in October 2011. In addition to the release of JavaFX 2.0, Oracle announced its commitment to take steps to open-source JavaFX, thus allowing the community to help move the platform forward. Open sourcing JavaFX will increase its adoption, enable a quicker turnaround time on bug fixes, and generate new enhancements.

Between JavaFX 2.1 and 2.2 the number of new features grew rapidly. Please refer to Table FM-1 for the numerous features included between versions 2.1 and 2.2. JavaFX 2.1 was the official release of the Java SDK on a MacOS. JavaFX 2.2 was the official release of the Java SDK on a Linux operating system.

The new Java 8 release was announced March 18, 2014. Java 8 has many new APIs and language enhancements, which includes lambdas, Stream API, Nashorn JavaScript engine, and JavaFX APIs. Relating to JavaFX 8, the following are such as: 3D graphics, Rich text support, and Printing APIs. To see all of the new features in Java 8 visit http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html.

Table FM-1. Historical Timeline of Major JavaFX Releases

image

What You Will Learn in This Book

The title of the book says it all: JavaFX 8: Introduction by Example. In this book you will be learning the new JavaFX 8 capabilities by following practical examples. These examples will, in turn, provide you with the knowledge needed to create your own rich client applications. Following Java’s mantra “Write once, run anywhere,” JavaFX also preserves this same sentiment. Because JavaFX 8 is written entirely in Java the language, you will feel right at home.

Most of the examples can be compiled and run under Java 7. However, most of them are designed to take advantage of Java 8’s language enhancements, and therefore Java 8 will be required. An example of a new Java 8 language feature used throughout is called lambda expressions and is discussed in Chapter 3. While working through this book with JavaFX 8 and Java 8, you will see that the new APIs and language enhancements will help you to become a more productive developer. Having said this, we encourage you to explore all of the new Java 8 capabilities.

This book covers JavaFX 8’s fundamentals, lambdas, properties, layouts, UI controls, Graphics, Animation, Custom UIs, Charts, Media, Web, 3D, Arduino, RaspberryPi, Touch events, and gestures.

Who This Book Is For

If you are a Java developer looking to take your client-side applications to the next level, you will find this book your guide to help you begin creating usable and aesthetically pleasing user interfaces. Also, if you are an experienced Java Swing, Flash/Flex, SWT or web developer who wants to learn how to create high-performant rich client-side applications, this is the book for you.

How This Book Is Structured

This book is arranged in a natural progression from beginner to intermediate and advanced level concepts. For the Java developer, none of the concepts mentioned in this book should be extremely difficult to figure out. This book is purely example-based and discusses major concepts before demonstrating applications. For each project, after showing the output from executing the code, we’ll provide a detailed explanation walking through the code. Each example can be easily adapted to meet your own needs when developing a game, media player, or your usual enterprise application. The more experienced a Java UI developer you are, the more freedom you’ll have to jump around to different chapters and examples throughout the book. However, any Java developer can progress through the book and learn the skills needed to enhance their everyday GUI applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset